Creates a radio button with text creates a radio

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: ault radio button with no text and icon. Creates a radio button with text. Creates a radio button with text and specifies whether the radio button is initially selected. Creates a radio button with an icon. Creates a radio button with text and an icon. Creates a radio button with text and an icon, and specifies whether the radio button is initially selected. 16 EE3206/EE5805 Java Programming & Applications Example: Using Radio Buttons Add three radio buttons named Red, Green, and Blue Red Green Blue into the preceding example to let the user choose the color of the message. ButtonDemo RadioButtonDemo Run CheckBoxDemo RadioButtonDemo EE3206/EE5805 Java Programming & Applications 17 JLabel A label is a display area for a short text, an image, or both. is javax.swing.JComponent javax.swing.JLabel -text: String -icon: javax.swing.Icon -horizontalAlignment: int -horizontalTextPosition: int -verticalAlignment: int -verticalTextPosition: int -iconTextGap: int +JLabel() +JLabel(icon: javax.swing.Icon) +JLabel(icon: Icon, hAlignment: int) +JLabel(text: String) +JLabel(text: String, icon: Icon, hAlignment: int) +JLabel(text: String, hAlignment: int) The label’s text. The label’s image icon. The horizontal alignment of the text and icon on the label. The horizontal text position relative to the icon on the label. The vertical alignment of the text and icon on the label. The vertical text position relative to the icon on the label. The gap between the text and the icon on the label (JDK 1.4). Creates a default label with no text and icon. Creates a label with an icon. Creates a label with an icon and the specified horizontal alignment. Creates a label with text. Creates a label with text, an icon, and the specified horizontal alignment. Creates a label with text and the specified horizontal alignment. 18 The get and set methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. EE3206/EE5805 Java Programming & Applications JLabel Constructors & Properties The constructors for labels are as follows: JLabel() JLabel(String text, int horizontalAlignment) JLabel(String text) JLabel(Icon icon) JLabel(Icon icon, int horizontalAlignment) JLabel(String text, Icon icon, int horizontalAlignment) JLabel inherits all the properties from JComponent and has many properties similar to the ones in JButton, such as text, icon, horizontalAlignment, verticalAlignment, horizontalTextPosition, verticalTextPosition, and iconTextGap. EE3206/EE5805 Java Programming & Applications 19 Using Labels // Create an image icon from image...
View Full Document

Ask a homework question - tutors are online