码:
list1items = new DefaultListModel();
list1items.addElement("-");
list1 = new JList(list1items);
list1.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
list1.setBounds(0,0, 100,100);
JScrollPane list1scr = new JScrollPane(list1);
list1scr.setPreferredSize(new Dimension(20, 20));
list1.setVisibleRowCount(8);
getContentPane().add (list1scr);
并且没有滚动条出现。当物品太多时,它们是隐藏的,我无法到达它们。如何解决呢?
最佳答案
getContentPane().add(list1scr);