public class J_01_FLOW_08 extends JApplet
{
JPanel p = new JPanel();//nedd a jpanel to add scroll
String s_value[] = {"black","red","pink","yellow","blue","orange"};
DefaultListModel dlm = new DefaultListModel();
JList l_list = new JList(dlm);
JScrollPane sp = new JScrollPane(l_list,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JLabel l_label = new JLabel();
Container c;
FlowLayout flow = new FlowLayout();
public void init()
{
c = getContentPane();
c.setLayout(flow);
for(String sv: s_value) //add all list in dlm
{
dlm.addElement(sv);
}
l_list.setVisibleRowCount(4);
l_list.setFixedCellHeight(30);
l_list.setFixedCellWidth(150);
l_list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); //selected as maany as you can
p.add(l_list);
p.add(sp);
p.add(l_label);
c.add(p);
}
}
for some reason its not print the scroll bar.