CEE 5110 Lecture Notes - Lecture 22: Layout Manager
![](https://new-preview-html.oneclass.com/pl62Dqo4LMV8QqJYy5GrmwPeyEX1aYOR/bg1.png)
Lecture - 22
•
Listeners (cont’d)
•
actionPerformed (or another listener method) takes a corresponding type of
event as a parameter.
•
Event objects have useful methods. For example, getSource returns the object
that produced this event.
•
A MouseEvent has methods getX, getY.
•
GUI Components Review
•
Java Methods Appendix C contains brief summaries of several Swing
components, their constructors, methods, and events.
•
For a complete specification refer to the Java Swing API docs.
•
JLabel
•
JButton
•
JCheckBox
•
etc.
•
Layouts
•
A layout manager is a strategy for placing components on the content pane or
another component (usually a panel).
•
In Java, the content pane and any GUI component is a Container.
•
A layout is chosen by calling the container’s setLayout method.
•
Layouts (cont’d)
•
Layouts are used to achieve some degree of platform independence and
scalability.
•
awt/Swing support several layout managers. Here we consider four:
FlowLayout
GridLayout
BorderLayout
BoxLayout