Unit 6: Exploring Swing

5th Semester

6.2 JTextField

JTextField is used for taking input of single line of text. It is most widely used text component. It has three constructors,

 

xample using JTextField

6.3 JButton

JButton class provides functionality of a button. JButton class has three constuctors,

It allows a button to be created using icon, a string or both. JButton supports ActionEvent. When a button is pressed an ActionEvent is generated.
Example


 

6.5 JCheckBox

JCheckBox class is used to create checkboxes in frame. Following is constructor for JCheckBox,

Example using JCheckBox

6.5 JRadioButton

Radio button is a group of related button in which only one can be selected. JRadioButton class is used to create a radio button in Frames. Following is the constructor for JRadioButton,

Example using JRadioButton

6.9 JComboBox

Combo box is a combination of text fields and drop-down list.JComboBox component is used to create a combo box in Swing. Following is the constructor for JComboBox,

Example using JComboBox