I l@ve RuBoard |
![]() ![]() |
Chapter 5. ButtonsButtons 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![]() The JMenuItem class shown here (and its subclasses, not shown) is not covered in this chapter; see Chapter 14 for details. |
I l@ve RuBoard |
![]() ![]() |