Chapter 5. Buttons


Buttons are simple UI components used to generate events when the user presses them. Swing buttons can display icons, text, or both. In this section, we'll introduce the ButtonModel interface and DefaultButtonModel class (which define the state of the button). Next, we'll look at the AbstractButton class (which defines much of the functionality for all button types). Finally, we'll look at four concrete subclasses of AbstractButton and see how they can be grouped together using a ButtonGroup.

Figure 5-1 shows the class hierarchy, with significant relationships between the button-related Swing classes. As we discussed in the introductory chapters, each button (AbstractButton) keeps a reference to a ButtonModel, which represents its state.

Figure 5-1. Button class diagram
figs/swng2.0501.gif

The JMenuItem class shown here (and its subclasses, not shown) is not covered in this chapter; see Chapter 14 for details.



Java Swing
Graphic Java 2: Mastering the Jfc, By Geary, 3Rd Edition, Volume 2: Swing
ISBN: 0130796670
EAN: 2147483647
Year: 2001
Pages: 289
Authors: David Geary

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net