Académique Documents
Professionnel Documents
Culture Documents
EVENT-DRIVEN PROGRAMMING
( For Reference purpose Only)
Button
● used to create a labeled button.
To create a Button:
● JButton b=new JButton("Click Here");
import javax.swing.*;
public class Frame {
public static void main(String[] args) {
JFrame f=new JFrame();
JButton b=new JButton("Click Here");
f.add(b);
f.setTitle("Welcome");
f.setLocation(200,200);
f.setSize(400,400);
f.setResizable(false);
f.setVisible(true);
}
}
Note : BUTTON in Single Frame.
Methods:
f.setDefaultCloseOperation(JFrame.EXIT
_ON_CLOSE);
}
}
Excellence and Service
CHRIST
Deemed to be University
Java JButton
Methods Description
Java JLabel
● The object of JLabel class is a component for placing text in a container.
● It is used to display a single line of read only text.
● The text can be changed by an application but a user cannot edit it directly.
● It inherits JComponent class.
public class JLabel extends JComponent implements SwingConstants,
Accessible
Constructor Description
Creates a JLabel instance with no image
JLabel()
and with an empty string for the title.
Creates a JLabel instance with the
JLabel(String s)
specified text.
Creates a JLabel instance with the
JLabel(Icon i)
specified image.
Creates a JLabel instance with the
JLabel(String s, Icon i, int
specified text, image, and horizontal
horizontalAlignment)
alignment.
Excellence and Service
CHRIST
Deemed to be University
Java JLabel
Methods Description
t returns the text string that a label
String getText()
displays.
Java JTextField
● The object of a JTextField class is a text component that allows the editing of
a single line text. It inherits JTextComponent class.
Constructor Description
Java JTextField
Methods Description
Java JTextArea
The object of a JTextArea class is a multi line region that displays text.
It allows the editing of multiple line text.
It inherits JTextComponent class
Constructor Description
Creates a text area that displays no text
JTextArea()
initially.
Creates a text area that displays specified
JTextArea(String s)
text initially.
Creates a text area with the specified
JTextArea(int row, int column) number of rows and columns that
displays no text initially.
Creates a text area with the specified
JTextArea(String s, int row, int
number of rows and columns that
column)
displays specified text.
Excellence and Service
CHRIST
Deemed to be University
Methods Description
Java JPasswordField
Java JCheckBox
Methods Description
Java JRadioButton
Constructor Description
Methods Description
Java JComboBox
Constructor Description
Methods Description
Java JList
● The object of JList class represents a list of text items. The list of text items
can be set up so that the user can choose either one item or multiple items. It
inherits JComponent class.
Constructor Description
Methods Description
Java JScrollBar
● The object of JScrollbar class is used to add horizontal and vertical scrollbar.
It is an implementation of a scrollbar. It inherits JComponent class.
Constructor Description
Java JPanel
Assignment
● Java JScrollPane
● Java JOptionPane
● Java JDialog
● Java JComponent