package graph;
/*下拉框、
* 列表框、
* 滚动窗格组件*/
import java.awt.*;
import javax.swing.*;
public class demo8 extends JFrame{
JPanel jp1,jp2;
JLabel jl1,jl2;
JComboBox jcb1;
JList jlist;
JScrollPane jsp;
public static void main(String[] args) {
// TODO Auto-generated method stub
demo8 demo = new demo8();
}
public demo8() {
jp1 = new JPanel();
jp2 = new JPanel();
jl1 = new JLabel("你的籍贯:");
jl2 = new JLabel("你喜欢的旅游地点");
String[] jg = {"baijing","shanghai","tianjin","hubei"};
jcb1 = new JComboBox(jg);
String[] dd = {"jiuzaigou","gugong","emeisan","changcheng","tiananmen"};
jlist = new JList<>(dd);
//设置希望显示多少个选项
jlist.setVisibleRowCount(3);
jsp = new JScrollPane(jlist);
//设置布局
this.setLayout(new GridLayout(3, 1));
//添加组件
jp1.add(jl1);
jp1.add(jcb1);
jp2.add(jl2);
jp2.add(jsp);
this.add(jp1);
this.add(jp2);
this.setSize(300,300);
this.setLocation(300, 500);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
java [24] 图形化 下拉框、列表框、和滚动窗格组件
猜你喜欢
转载自blog.csdn.net/qq_38125626/article/details/81286592
今日推荐
周排行