JAVA radio button, check button

Source: Internet
Author: User

//radio buttons and check buttonsImportjava.awt.*;Importjavax.swing.*; Public classJiemian6extendsjframe{JPanel mb1,mb2,mb3; //Panel DefinitionJButton an1,an2;//button DefinitionJLabel bq1,bq2;//Label DefinitionJcheckbox Fxk1,fxk2,fxk3;//Multi-box definitionJradiobutton dx1,dx2;//radio button DefinitionButtongroup Dxz;//Put the radio button in a group, the default function is to choose only one, equivalent to the name of the HTML         Public Static voidMain (string[] args) {//to run this class of construction methodsJiemian6 Jiemian =NewJiemian6 (); }         PublicJiemian6 () {//Create a panelMB1 =NewJPanel (); MB2=NewJPanel (); MB3=NewJPanel (); //Create buttonBQ1 =NewJLabel ("Features:"); BQ2=NewJLabel ("Gender:"); An1=NewJButton ("register"); An2=NewJButton ("Cancel"); FXK1=NewJcheckbox ("Music"); FXK2=NewJcheckbox ("Sport"); FXK3=NewJcheckbox ("literary"); Dx1=NewJradiobutton ("Male"); DX2=NewJradiobutton ("female"); //Use grid layout         This. setlayout (NewGridLayout (3,1)); //Add a group so that it can select only oneDXZ =NewButtongroup ();        Dxz.add (DX1);                Dxz.add (DX2); //Add a button to a panelMb1.add (BQ1);        Mb1.add (FXK1);        Mb1.add (FXK2);        Mb1.add (FXK3);        Mb2.add (BQ2);        Mb2.add (DX1);        Mb2.add (DX2);        Mb3.add (AN1);                    Mb3.add (AN2); //Add a panel to the interface         This. Add (MB1);  This. Add (MB2);  This. Add (MB3); //Set Window caption         This. Settitle ("Layout Integrated Application"); //Set the width height of the window         This. SetSize (300,150); //The Settings window appears for the location of the screen         This. setlocation (100,100); //no pulling the big pull small         This. setresizable (false); //releasing a resource after closing a window         This. Setdefaultcloseoperation (Jframe.exit_on_close); //Output Window         This. setvisible (true); }    }

JAVA radio button, check button

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.