|
|
The java.awt Package Certification Objectives
NOT REQUIRED FOR 1.4 EXAM
- Write code using component, container, and LayoutManager classes of the java.awt package to present a GUI with a specified appearance and resize behaviour, and distinguish the responsibilities of layout managers from those of containers.
- Write code to implement listener classes and methods, and in listener methods, extract information from the event to determine the affected component, mouse position, nature and time of the event. State the classname for any specified event listener interface in the java.awt.event package.
| Pay Attention to which Layout Managers implement LayoutManager2 |
- one thing I discovered (after I wrote the exam!) that is of prime importance in the way containers handle components when they are resized is knowing which Layout Interface the active LayoutManager implements. Any Layout Manager that extends the LayoutManager2 Interface keeps track of their own components.
- What this means in practice is that if the layout manager is set after components have been added to the container and the layout manager implements the LayoutManager2 interface, no components will be visible.
- LayoutManager2 type managers do not query the container for a list of components, they maintain their own list.
- FlowLayout and GridLayout, both implement LayoutManager. When the container is resized they will query the container for a list of the components and then layout them out according to their contract.
- CardLayout, BorderLayout, GridBagLayout, BoxLayout, and OverlayLayout implement the LayoutManager2 interface. If the container is resized they rely on their own, internal list of components. Components added to a container before the LayoutManager was added will not be known and hence not included in the layout when the container is resized.
|
|