Swing check box (jcheckbox) Radio Box (Jradiobutton) Special note: The same group of radio buttons, you must first create a buttongroup, and then place the radio button in Buttongroup package Gui;import javax.swing.jbutton;import javax.swing.jframe;import Javax.swing.jpanel;import Javax.swing.JLabel; Import Javax.swing.jcheckbox;import Javax.swing.jradiobutton;import Javax.swing.buttongroup;import java.awt.gridlayout;/*** Radio box, check box * Created by admin on 2017/7/6.*/public class Myselect extends jframe{//define the required components here Priva Te JButton JButton, jbutton2;private JPanel JPanel, JPanel2, Jpanel3;private JLabel JLabel, jlabel2;private jcheckbox Jche CkBox1, JCheckBox2, jcheckbox3;private buttongroup buttongroup;private Jradiobutton Jradiobutton, JRadioButton2, JRadioButton3, jradiobutton4;public static void Main (string[] args) {Myselect myselect = new Myselect ();} Construction method Public Myselect () {//panel JPanel = new JPanel (); jPanel2 = new JPanel (); JPanel3 =new JPanel ();//Button JButton = new Jbutto N ("OK"); jButton2 = new JButton ("Cancel");//Label JLabel = new JLabel ("select"); JLabel2 = new JLabel ("Environment");//CheckJCheckBox1 = new Jcheckbox ("Python"), JCheckBox2 = new Jcheckbox ("Java"); jCheckBox3 = new Jcheckbox ("Python");// Radio Jradiobutton = new Jradiobutton ("Linux"), JRadioButton2 = new Jradiobutton ("Unix"); JRadioButton3 = new Jradiobutton (" Windows "); jRadioButton4 = new Jradiobutton (" Mac OS ");//Radio Box Groupbuttongroup = new Buttongroup (); Buttongroup.add ( Jradiobutton); Buttongroup.add (JRadioButton2); Buttongroup.add (JRadioButton3); Buttongroup.add (JRADIOBUTTON4); jpanel.add (JLabel); Jlabel.add (JCheckBox1); Jpanel.add (JCheckBox2); Jpanel.add (JCHECKBOX3); Jpanel2.add ( JLABEL2); Jpanel2.add (Jradiobutton); Jpanel2.add (JRadioButton2); Jpanel2.add (JRadioButton3); Jpanel2.add ( JRADIOBUTTON4); jpanel3.add (JButton); Jpanel3.add (JButton2); this.setlayout (New GridLayout (3, 1)); This.add (JPanel); This.add (JPanel2); This.add (JPANEL3);//Set JFrame properties This.settitle ("project"); This.setlocation (500, 250) ; This.setsize (n); this.setresizable (false); this.setdefaultcloseoperation (Jframe.exit_on_close); This.setvisible (True);}}  
Java GUI programming (swing) three Swing radio check box component