下拉框

一、代码如下

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

	
}

 

转载于:https://www.cnblogs.com/wujianbo123/p/7553702.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值