Java GUI programming (swing) three Swing radio checkbox component

Source: Internet
Author: User

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);}} &nbsp

Java GUI programming (swing) three Swing radio check box component

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.