You are here:   HomeJava ProgrammingSwingFileFilter Java Swing Example
by Dinesh Thakur Category: Swing

 

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>*/

ListMultiple in Java Swing Example





Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article