import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class JavaExampleListMultipleInJApplet extends JApplet implements ListSelectionListener
{
JList Lst;
public void init()
{
Container Cntnr = getContentPane();
String[] Itms = new String[12];
for(int loop_indx = 0; loop_indx <= 11; loop_indx++)
{
Itms[loop_indx] = "ITEM : " + loop_indx;
}
Lst = new JList(Itms);
JScrollPane ScrlPn = new JScrollPane(Lst);
Lst.setVisibleRowCount(5);
Lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
Lst.addListSelectionListener(this);
Cntnr.setLayout(new FlowLayout());
Cntnr.add(ScrlPn);
}
public void valueChanged(ListSelectionEvent e1)
{
int[] Indxs = Lst.getSelectedIndices();
String OutStrng = "You Select:";
for(int loop_indx = 0; loop_indx < Indxs.length; loop_indx++)
{
OutStrng += " ITEM " + Indxs[loop_indx];
}
showStatus(OutStrng);
}
}
/*<APPLET CODE=JavaExampleListMultipleInJApplet.class WIDTH=310 HEIGHT=210> </APPLET>*/