Advanced JAVA Programming
(COURSE CODE: B19CS2201)
Exploring Swing
Sri. M.Jeevana Sujitha
Assistant Professor
Department of Computer Science and Engineering SRKR Engineering College, Bhimavaram, A.P. - 534204
OBJECTIVES
The Objective of this lecture is
Exploring Swing
JButton: The JButton class is used to create a labeled button that has platform independent implementation.
pushed.
Example:
JButton b=new JButton("Click Here");
Exploring Swing
JLabel: It is used to display a single line of read only text.
cannot edit it directly.
specified text.
Example:
JLabel l=new JLabel(“username");
Exploring Swing
JTextField: The object of a JTextField class is a text component that allows the editing of a single line text.
Constructors:
TextField initialized with the specified text and columns.
Example:
JTextField t=new JTextField(“srinu”);
Exploring Swing
JTextArea: The object of a JTextArea class is a multi line region that displays text.
with the specified number of rows and columns that displays specified text.
Example:
JTextArea area=new JTextArea(“palakollu");
Exploring Swing
JPasswordField: The object of a JPasswordField class is a text component specialized for password entry.
JPasswordField with the specified number of columns.
initialized with the specified text.
Example:
JPasswordField value = new JPasswordField();
Exploring Swing
JCheckBox: The JCheckBox class is used to create a checkbox.
Constructors:
box with text.
Example:
JCheckBox checkBox1 = new JCheckBox("C++");
JCheckBox checkBox2 = new JCheckBox("Java", true);
Exploring Swing
JRadioButton: The JRadioButton class is used to create a radio button.
Constructors:
Example:
JRadioButton r1=new JRadioButton("Male"); JRadioButton r2=new JRadioButton("Female");
Exploring Swing
JComboBox: The object of Choice class is used to show popup menu of choices.
Choice selected by user is shown on the top of a menu.
Constructors:
contains the elements in the specified array.
Example:
String languages[]={"C","C++","C#","Java","PHP"};
final JComboBox cb=new JComboBox(languages);
Exploring Swing
JTable: The JTable class is used to display data in tabular form. It is composed of rows and columns.
Constructors:
String
a table with the specified data.
Example:
String data[][]={ {"101","Amit","CSE"},
{"102","Jai","ECE"},
{"101","Sachin","IT"}};
column[]={"ROLLNO","NAME","DEPARTMENT"};
JTable jt=new JTable(data,column);
Exploring Swing
JTree: The JTree class is used to display the tree structured data or hierarchical data.
Exploring Swing
JTabbedPane: The JTabbedPane class is used to switch between a group of components by clicking on a tab with a given title or icon.
Exploring Swing
JScrollPane: A JscrollPane is used to make scrollable view of a component.
THANK YOU