🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ package gui.a8; import java.awt.*; import javax.swing.*; //下拉列表框和滚动条 public class Test extends JFrame{ JPanel mb1,mb2; JLabel bq1,bq2; JComboBox xlk;//下拉框 JList lb;//列表 JScrollPane gd;//滚动 public static void main(String[] args) { Test lx=new Test(); } public Test(){ mb1=new JPanel(); mb2=new JPanel(); bq1=new JLabel("籍贯"); bq2=new JLabel("学历"); String[] jg={"北京","天津","上海","重庆"}; xlk=new JComboBox(jg); String[] xl={"高中","大专","本科","硕士","博士"}; lb=new JList(xl); lb.setVisibleRowCount(3); gd=new JScrollPane(lb); this.setLayout(new GridLayout(2,1)); mb1.add(bq1); mb1.add(xlk); mb2.add(bq2); mb2.add(gd); //mb2.add(lb); this.add(mb1); this.add(mb2); this.setTitle("用户调查"); this.setSize(200,190); this.setLocation(300,280); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } } ~~~ ![](https://box.kancloud.cn/9b2d20a1ab91e55907699751c54f70d4_217x205.png)