![]() ![]() ![]() JRadioButton jcb = new JRadioButton("A") //creating JRadioButton.Īdd(jcb) //adding JRadioButton to frame. Following is the constructor for JRadioButton, JRadioButton(String str)Įxample using JRadioButton import javax.swing.* JRadioButton class is used to create a radio button in Frames. Radio button is a group of related button in which only one can be selected. jcb = new JCheckBox("maybe") //creating JCheckBox. jcb = new JCheckBox("no") //creating JCheckBox.Īdd(jcb) //adding JCheckBox to frame. JCheckBox jcb = new JCheckBox("yes") //creating JCheckBox.Īdd(jcb) //adding JCheckBox to frame. Following is constructor for JCheckBox, JCheckBox(String str)Įxample using JCheckBox import javax.swing.* JCheckBox class is used to create checkboxes in frame. SetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) JTextField jtf = new JTextField(20) //creating JTextField. It has three constructors, JTextField(int cols)Ĭols represent the number of columns in text field.Įxample using JTextField import javax.swing.* JTextField is used for taking input of single line of text. SetSize(400, 400) //setting size of Jframe SetLayout(new FlowLayout()) //setting layout using FlowLayout object SetDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) //setting close operation. JButton bt2 = new JButton("No") //Creating a No Button. ![]() JButton bt1 = new JButton("Yes") //Creating a Yes Button. When a button is pressed an ActionEvent is generated.Įxample using JButton import javax.swing.* ![]() It allows a button to be created using icon, a string or both. JButton class has three constuctors, JButton(Icon ic) JButton class provides functionality of a button. They all are derived from JComponent class. All these components are lightweight components. Swing Framework contains a large set of components which provide rich functionalities and allow high level of customization. Method Overriding with Exception Handling. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |