Java Interview Questions - AWT
1. What is the difference between the paint() and repaint() methods?
You should call this method if you want a component to repaint itself or to change its look (but not the size). One more thing i want to add to this all above answers that paint() should not be overridden by user. The repaint() method is used to make paint() method to be invoked by the AWT painting thread.
2. What is the relationship between clipping and repainting under AWT?
When a window is repainted by the awt painting thread,it sets the clipping regions to the area of the window that requires repainting.
3. What is a layout manager and what are different types of layout managers available in java AWT?
The layout manager automatically positions all the components within the container. If we do not use layout manager then also the components are positioned by the default layout manager.
Several AWT and Swing classes provide layout managers for general use BorderLayout:
- BoxLayout
- CardLayout
- FlowLayout
- GridBagLayout
- GridLayout
- GroupLayout
- SpringLayout
4. What is a container? Explain how components are added to a container?
Container is a predefined class present java.awt package and it is used to contains any components. add() is a predefined method which is used to add a component to container in java.