4 the state of the button true if the check box or

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: icon on the button (JDK 1.4). The state of the button. True if the check box or radio button is selected, false if it's not. EE3206/EE5805 Java Programming & Applications 5 The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. -iconTextGap: int -selected(): boolean JButton JButton inherits AbstractButton and provides several constructors to create buttons. javax.swing.AbstractButton javax.swing.JButton +JButton() +JButton(icon: javax.swing.Icon) +JButton(text: String) +JButton(text: String, icon: Icon) Creates a default button with no text and icon. Creates a button with an icon. Creates a button with text. Creates a button with text and an icon. EE3206/EE5805 Java Programming & Applications 6 JButton Constructors and Properties JButton() JButton JButton(String text) JButton(String JButton(String text, Icon icon) JButton(String JButton(Icon icon) JButton(Icon text text icon icon mnemonic mnemonic horizontalAlignment horizontalAlignment verticalAlignment verticalAlignment horizontalTextPosition horizontalTextPosition verticalTextPosition verticalTextPosition iconTextGap iconTextGap EE3206/EE5805 Java Programming & Applications 7 Default Icons, Pressed Icon, and Rollover Icon A regular button has a default icon, pressed icon, and rollover icon. Normally, you use the default icon. All other icons are for special effects. A pressed icon is displayed when a button is pressed and a rollover icon is displayed when the mouse is over the button but not pressed. (A) Default icon (B) Pressed icon (C) Rollover icon Run TestButtonIcons EE3206/EE5805 Java Programming & Applications 8 Horizontal Alignments Horizontal alignment specifies how the icon and text are placed Horizontal horizontally on a button. You can set the horizontal alignment using one of the five constants: You LEADING, LEFT, CENTER, RIGHT, TRAILING. At present, LEADING and LEFT are the same and TRAILING and RIGHT are the same. The default horizontal alignment is SwingConstants.TRAILING. The EE3206/EE5805 Java Programming & Applications 9 Vertical Alignments Vertical alignment specifies how the icon and text are placed vertically Vertical on a button. You can set the vertical alignment using one of the three constants: TOP, CENTER, BOTTOM. The default vertical alignment is SwingConstants.CENTER. The EE3206/EE5805 Java Programming & Applications 10 Horizontal Text Positions Horizontal text position specifies the horizontal position of the text...
View Full Document

This note was uploaded on 01/11/2011 for the course EE 3206 taught by Professor Cwting during the Spring '07 term at City University of Hong Kong.

Ask a homework question - tutors are online