zoukankan      html  css  js  c++  java
  • 下拉框

    一、代码如下

    package www.tainiu.gui;
    
    import java.awt.GridLayout;
    
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    
    public class ac__XiaLaKuang__V1 extends JFrame {
    	JPanel jp1,jp2;
    	JLabel jl1,jl2;
    	JComboBox jcb;
    	JList jl;
    	JScrollPane jsp;
    	
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		ac__XiaLaKuang__V1 xv= new ac__XiaLaKuang__V1();
    	}
    	
    	public ac__XiaLaKuang__V1() {
    		// TODO Auto-generated constructor stub
    		//定义组件
    		this.jp1= new JPanel();
    		this.jp2= new JPanel();
    		this.jl1= new JLabel("您的籍贯是");
    		this.jl2= new JLabel("您喜欢旅游的地方是");
    		
    		String[] jg= {"四川", "北京", "上海", "重庆", "云南"};
    		this.jcb= new JComboBox(jg);
    		
    		String[] lvjd={"乐山", "眉山", "卧龙", "恐龙博物馆", "故宫", "长城", "颐和园"};
    		this.jl= new JList(lvjd);
    		this.jl.setVisibleRowCount(2);
    		jsp= new JScrollPane(this.jl);
    		
    		
    		//布局格式
    		this.setLayout(new GridLayout(3, 1));
    		//添加组件
    		this.jp1.add(this.jl1);
    		this.jp1.add(this.jcb);
    		this.jp2.add(this.jl2);
    		//this.jp2.add(this.jl);
    		this.jp2.add(jsp);
    		
    		this.add(this.jp1);
    		this.add(this.jp2);
    		
    		//容器属性设置
    		this.setSize(400, 150);
    		this.setLocation(200, 200);
    		//this.setResizable(false);
    		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    		this.setVisible(true);
    	}
    
    	
    }
    
  • 相关阅读:
    C# GetHashCode 部分冲突列表 数字字符串版本
    Amazon Dynamo DB
    SCTP 一句话介绍
    SystemTap 使用以及安装
    Windows Azure Service Disruption on Feb 29th
    发布ASP.NET MVC3网站
    SQLServer数据集合的交、并、差集运算
    DataTable的几个函数
    oracle创建表空间以及用户的语句
    asp.net mvc3及odp.net资料下载地址
  • 原文地址:https://www.cnblogs.com/wujianbo123/p/7553702.html
Copyright © 2011-2022 走看看