JAVA drop-down list and scroll bar

Source: Internet
Author: User

//Drop- down lists and scroll barsImportjava.awt.*;Importjavax.swing.*; Public classJiemian7extendsjframe{JPanel MB1,MB2; //Panel DefinitionJLabel bq1,bq2;//Label DefinitionJComboBox xlk;//Drop- down boxJList lb;//radio button DefinitionJScrollPane GD;//scroll bar         Public Static voidMain (string[] args) {//to run this class of construction methodsJiemian7 Jiemian =NewJiemian7 (); }         PublicJiemian7 () {//Create a panelMB1 =NewJPanel (); MB2=NewJPanel (); BQ1=NewJLabel ("Hometown"); BQ2=NewJLabel ("Education"); String[] JG= {"Beijing", "Tianjin", "Shanghai", "Chongqing"}; Xlk=NewJComboBox (JG); String[] XL= {"High school", "College", "undergraduate", "Master", "PhD"}; LB=NewJList (XL); Lb.setvisiblerowcount (3);//How many rows are scrolledGd=NewJScrollPane (LB);//Unlike radio buttons, here you add a scroll component to the Panel//Use grid layout         This. setlayout (NewGridLayout (2,1)); //Add a button to a panelMb1.add (BQ1);        Mb1.add (XLK);        Mb2.add (BQ2);                    Mb2.add (GD); //Add a panel to the interface         This. Add (MB1);  This. Add (MB2); //Set Window caption         This. Settitle ("drop-down list and scroll bar"); //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 drop-down list and scroll bar

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.