下拉框,列表框
作者:互联网
下拉框,列表框
下拉框:
package com.zhang.Study.下拉框列表框;
import javax.swing.*;
import java.awt.*;
//下拉框
public class TestComboboxDemo extends JFrame {
public TestComboboxDemo(){
Container container = this.getContentPane();
JComboBox status = new JComboBox();//创建下拉框
status.addItem(null);
status.addItem("12");
status.addItem("23");
status.addItem("34");
container.add(status);
setVisible(true);
this.setSize(500,300);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new TestComboboxDemo();
}
}
列表框:
package com.zhang.Study.下拉框列表框;
import javax.swing.*;
import java.awt.*;
public class liebiaokuang extends JFrame {
public liebiaokuang (){
Container container = this.getContentPane();
//生成列表内容
String [] contents ={"1","2","3"};
//把内容放入列表
JList jList = new JList(contents);
container.add(jList);
setVisible(true);
this.setSize(500,300);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new liebiaokuang();
}
}
标签:status,列表框,addItem,public,new,下拉框 来源: https://www.cnblogs.com/zhangtiedangg/p/15670117.html