JAVA里面写一个下拉框,显示1-25的排序。。
1个回答
展开全部
import java.awt.FlowLayout;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class Test extends JFrame {
public Test() {
Vector<Integer> items = new Vector<Integer>();
for (int i = 1; i <= 25; i++) {
items.add(i);
}
JComboBox cb = new JComboBox(items);
this.setLayout(new FlowLayout());
this.add(cb);
}
public static void main(String[] args) {
Test t = new Test();
t.setSize(200, 200);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
t.setVisible(true);
}
}
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class Test extends JFrame {
public Test() {
Vector<Integer> items = new Vector<Integer>();
for (int i = 1; i <= 25; i++) {
items.add(i);
}
JComboBox cb = new JComboBox(items);
this.setLayout(new FlowLayout());
this.add(cb);
}
public static void main(String[] args) {
Test t = new Test();
t.setSize(200, 200);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
t.setVisible(true);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询