Skip to Main Content
Java Swing, 2nd Edition
book

Java Swing, 2nd Edition

by Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole
November 2002
Intermediate to advanced content levelIntermediate to advanced
1278 pages
38h 26m
English
O'Reilly Media, Inc.
Content preview from Java Swing, 2nd Edition

The AbstractButton Class

AbstractButton is an abstract base class for all button components (JButton, JToggleButton, JCheckBox, JRadioButton, and JMenuItem and its subclasses). Since it provides functionality common to all types of buttons, we’ll cover it here before getting to the concrete button classes.

AbstractButton provides much of the functionality associated with the interaction between the various concrete button classes and their ButtonModel objects. As we mentioned earlier, buttons in Swing can be made up of an image (Icon ), text, or both. The relative positions of the text and icon are specified exactly as they are with the JLabel class.

Image buttons may specify as many as seven different images, allowing the button to be displayed differently depending on its current state. The seven icons are described in Table 5-5, with the other properties defined by AbstractButton.

Properties

The AbstractButton class defines the properties shown in Table 5-5.

Table 5-5. AbstractButton properties

Property

Data type

get

is

set

Default value

action1.3

Action

·

 

·

null

actionCommand

String

·

 

·

null

borderPaintedb

boolean

 

·

·

true

contentAreaFilledb

boolean

 

·

·

true

disabledIconb

Icon

·

 

·

null

disabledSelectedIconb

Icon

·

 

·

null

displayedMnemonicIndex1.4

int

·

 

·

-1

enabledo

boolean

 

·

·

true

focusPaintedb

boolean

 

·

·

true

horizontalAlignmentb

int

·

 

·

CENTER

horizontalTextPositionb

int

·

 

·

TRAILING1.4

iconb

Icon

·

 

·

null

iconTextGap1.4

int

·

 

·

4

labeld

String

·

 

·

Same as text

marginb

Insets

·

 

·

null

mnemonicb

int

·

 

·

KeyEvent.VK_UNDEFINED ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Threads, 3rd Edition

Java Threads, 3rd Edition

Scott Oaks, Henry Wong

Publisher Resources

ISBN: 0596004087Errata PageSupplemental Content