What do the invalidate and validate methods do?
Ans : The invalidate and validate methods control when a container lays out its components. Component layouts in the AWT are dynamic. A change in one container, such as resizing a text field or adding a button, can spread up the containment hierarchy and trigger layout adjustments in many other containers. For efficiency, the AWT splits the process into two independently controllable parts: • marking the containers whose layouts are no longer valid • redoing the layout of containers marked as invalid The invalidate method handles the first step. It marks containers as needing a new layout but doesn’t perform that layout itself. If a text field is resized, for instance, the AWT will invoke invalidate on the text field and on the text field’s parent. When needed, the AWT propagates invalidate calls up through the containment hierarchy. All the real action happens in validate. Invoking validate on a container checks whether that container is marked as invalid, that is, in need of a new la