Radford Burger
Radford Burger
Radford Burger
Agenda
GUI: Re-cap
LayoutManagers
Menus
Inner class for even-handling
Sorting an Arraylist of custom objects
Practical exercise
a) Try to add some GUI
components to the
NORTH area.
Every SWING controls inherits properties from the following Component class hiearchy.
Gui: Recap
list of commonly used controls while designing GUI using SWING:
Class Description
JLabel
Class Placing text in a container
Description
JButton
JLabel
JCheckBox
JButton
JRadioButton
JCheckBox
JColorChooser
JRadioButton
JTextField
JColorChooser Editing of single line of text
Class description
BorderLayout Arranges components to fit in 5 regions
GridLayout Places components in a rectangular grid
FlowLayout Arranges components in a directional flow
CardLayout Treats each component as a card. Only 1
card is visible at a time
GridBagLayout Aligns components vertically or
horizontally, or along their baseline
Gui: Menus
As we know that every top-level window has a menu
bar associated with it.
This menu bar consists of various menu choices
available to the end user.
Further, each choice contains a list of options, which is
called drop-down menus.
Gui: Menus
list of menu controls:
Class description
JMenuBar Top-level window
JMenu Pull-down menu component displayed
from the menubar
JMenuItem Available options in the pull-down menu
Gui: Menus
Sequence of steps to create
menus
1. Create JMenuBar object and attach to frame
2. Create JMenu object
3. Create JMenuItem objects and attach to JMenu
object
4. Attach JMenu object to JMenuBar object
Sequence of steps to create
menus
1. Create JMenuBar object and attach to frame
mBar.add(fileMenu);
Event-handling of menus
… and Prac 6
Conclusion