posted 22 years ago
How can i set the size of the display list?
and how can i make it display 3 choices at a time?
Below is my current code:
//items in thr list box
listModel = new DefaultListModel();
listModel.addElement("---ALL---");
//to display the products
for(int i=1; i<=9; i++)
{listModel.addElement("Product " + i);}
//Create the list and put it in a scroll pane
list = new JList(listModel);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//set the Visible number of item that a user can view at a glance
list.setVisibleRowCount(3);
//Set the font of the items display
Font displayFont = new Font("Serif", Font.BOLD, 12);
list.setFont(displayFont);
//set the default selected item
list.setSelectedIndex(0);
//list.addListSelectionListener(this);
list.setLength(20);
JScrollPane listScrollPane = new JScrollPane(list);
so is there a code like
list.setSize(20); :roll: