by Dinesh Thakur Category: AWT and Applets


import java.awt.*;

import javax.swing.*;
import java.awt.event.*;
public class JavaExampleDoubleListInJApplet extends JApplet implements MouseListener
      public void init()
           Container Cntnr = getContentPane();
           String[] Itms = {"Item One", "Item Two", "Item Three", "Item Four",
                                    "Item Five", "Item Six", "Item Seven", "Item Eight",
                                    "Item Nine", "Item Ten", "Item Eleven", "Item Twelve"};
           JList Lst=new JList(Itms);
           Cntnr.setLayout(new FlowLayout());
           Cntnr.add(new JScrollPane(Lst));
         public void mouseClicked(MouseEvent e1)
             JList JLst = (JList)e1.getSource();
             int index = JLst.locationToIndex(e1.getPoint());
             String s1 = (String)JLst.getSelectedValue();
             String OutStrng = new String("Number of clicks for item " +s1 + ": " + e1.getClickCount());
             public void mouseEntered(MouseEvent e) {}
             public void mouseExited(MouseEvent e) {}
             public void mousePressed(MouseEvent e) {}
             public void mouseReleased(MouseEvent e) {}
/*<APPLET CODE=JavaExampleDoubleListInJApplet.class WIDTH=310 HEIGHT=210 >\</APPLET>*/
DoubleList Java Example

Popular Article