Chapter 9
Section 9.1
- combine
all we’ve learned to make a functional GUI
- events
and listeners, containers, components, layout managers, special features
- layout
managers specify how components are arranges in a container
- we’ve
mostly used classes from the Abstract Windowing Toolkit package (java.awt)
- Java 2
introduces Swing classes, like JButton which has more functionality than
Button class
Section 9.2
- Applet
class can only show AWT components
- to
show Swing components, must inherit from JApplet
- frame
is free standing window that can be repositioned anywhere
- panel
can’t be displayed on its own but can be added to a container
- can
put graphics in applets and applications – applications need a container
other than an applet to use as their window
- WindowEvent
comes with a window, and has WindowListeners
- listing
9.1, 9.2, 9.3, p. 412-414
Section 9.3
- components
have established preferred size, minimum size, and max size
- labels
are text, images or both
- listing
9.4, 9.5, p. 416-417
- push
buttons, check box, radio buttons
- radio
buttons are mutually exclusive, check box buttons are not
- listing
9.6, 9.7, p. 419-423
- combo
box allows several options, and can be editable or not
- listing
9.8, 9.9, p.425-428
Section 9.4
- layout
manager governs how components are laid out in a container
- layout
manager is consulted whenever container might need to change appearance
- many
predefined ones, like flow, border, box, card, grid, gridbag and overlay
- flow
puts components in a row
- border
puts them in north, south, east, west and center
- box
puts them horizontally or vertically in a row or column
Section 9.5
- can
add special features like tool tips, borders and mnemonics
Section 9.6
- deciding
what to add to your GUI has to do with knowing the user, preventing user
errors, optimizing user abilities and being consistent