Anda di halaman 1dari 3

advance java

2.basic swing components

1)JComponent features-

The JComponent class provides the following function

Tool tips-By specifying a string with the


setToolTipText method, you can provide help to
users of a component. When the cursor pauses
over the component, the specified string is
displayed in a small window that appears near
the component.

Border-The setBorder method allows you to


specify the border that a component displays
around its edges.

Double buffering-Double buffering smooths on-


screen painting.

Custom properties-You can associate one or more


properties (name/object pairs) with any
JComponent.

2)JLabel - With the JLabel class, you can display


unselectable text and images. If you need to create a
component that displays a string, an image, or both,
you can do so by using or extending JLabel.

constructor -
1) JLabel()-Creates a JLabel instance with no image
and with an empty string for the title.

2)JLabel(Icon image)-Creates a JLabel instance with


the specified image.

3)JLabel(String text)-Creates a JLabel instance with


the specified text.

3)JTextField- A text field is a basic text control


that enables the user to type a small amount of text.
When the user indicates that text entry is complete
(usually by pressing Enter), the text field fires an
action event. If you need to obtain more than one line
of input from the user, use a text area.

*constructors -
1)JTextField()-Constructs a new TextField.

2)JTextField(String text)-Constructs a new TextField


initialized with the specified text.

4)JButton -The class JButton is an implementation


of a push button. This component has a label and
generates an event when pressed.

*Constructor-

1)JButton()-Creates a button with no set text or


icon.

2)JButton(String text)-Creates a button with text.

5)JCheckbox- The class JCheckBox is an


implementation of a check box.an item that can be
selected or deselected, and which displays its state to
the user.

*constructors-
1)JCheckBox()-Creates an initially unselected check
box button with no text, no icon.

2)JCheckBox(String text)-Creates an initially


unselected check box with text.

3)JCheckBox(Action a)-Creates a check box where


properties are taken from the Action supplied.

6)JRadioButton-The class JRadioButton is an


implementation of a check box.an item that can be
selected or deselected, and which displays its state to
the user.

*constructors-
1)JRadioButton()-Creates an initially unselected radio
button with no set text.

2)JRadioButton(Action a)-Creates a radiobutton where


properties are taken from the Action supplied.

3)JRadioButton(Icon icon)-Creates an initially


unselected radio button with the specified image but
no text

Anda mungkin juga menyukai