Java GUI programming (swing) four swing drop-down box, list box, scrolling window

Source: Internet
Author: User

Drop-down box (JComboBox) list box (JList) scrolling window (jscrollpane)  package gui;import java.awt.gridlayout;import javax.swing.*;  /*** dropdown box, list box, window scroll * Created by admin on 2017/7/9.*/public class Scroll extends jframe{//define required components private JList Jlist;priva Te JComboBox jcombobox;private jscrollpane jscrollpane;private JLabel JLabel, jlabel2;private JPanel JPanel, JPanel2; public static void Main (string[] args) {Scroll Scroll = new Scroll ();} Public Scroll () {jPanel = new JPanel (); jPanel2 = new JPanel (); JLabel = new JLabel ("province"); JLabel2 = new JLabel ("City"); String [] province = {"Guangxi", "Guangdong", "Hunan"};//dropdown box JComboBox = new JComboBox (province); String [] City = {"Nanning", "Liuzhou", "Guangzhou", "Shenzhen", "Changsha"};//list box JList = new JList (city); Jlist.setvisiblerowcount (3);//Window scrolling Jscrollpan E = new JScrollPane (jList), This.setlayout (New GridLayout (2, 1)); Jpanel.add (JLabel); Jpanel.add (JComboBox);  Jpanel2.add (JLABEL2); Jpanel2.add (JScrollPane);  this.add (JPanel); This.add (JPanel2); This.settitle ("Java"); This.setlocation (this.setsize);This.setdefaultcloseoperation (Jframe.exit_on_close); this.setvisible (True);}}      

Java GUI programming (swing) four swing drop-down box, list box, scrolling window

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.