Example usage for javax.swing JList getListSelectionListeners

List of usage examples for javax.swing JList getListSelectionListeners

Introduction

In this page you can find the example usage for javax.swing JList getListSelectionListeners.

Prototype

@BeanProperty(bound = false)
public ListSelectionListener[] getListSelectionListeners() 

Source Link

Document

Returns an array of all the ListSelectionListener s added to this JList by way of addListSelectionListener .

Usage

From source file:Main.java

public static void main(final String args[]) {
    String labels[] = { "A", "B", "C", "D", "E" };
    JFrame frame = new JFrame("Sizing Samples");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JList jlist1 = new JList();
    jlist1.setListData(labels);/*w  ww . j  ava 2 s  .co m*/

    jlist1.setVisibleRowCount(4);
    JScrollPane scrollPane1 = new JScrollPane(jlist1);
    frame.add(scrollPane1, BorderLayout.NORTH);

    ListSelectionListener[] lis = jlist1.getListSelectionListeners();

    frame.setSize(300, 350);
    frame.setVisible(true);
}

From source file:Main.java

public static void addDoubleClickEvent(JList list) {
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            JList source = (JList) e.getSource();
            if (e.getClickCount() == 2) {
                ListSelectionListener[] listeners = source.getListSelectionListeners();
                for (int i = 0; i < listeners.length; i++) {
                    listeners[i].valueChanged(new ListSelectionEvent(source, source.getSelectedIndex(),
                            source.getSelectedIndex(), false));
                }//www.jav  a  2  s  .c o m
            }
        }
    });
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Removes the ListSelection Listeners./*from  w ww  .  jav a 2s  .com*/
 * @param comp the comp
 */
public static void removeListSelectionListeners(final JList comp) {
    if (comp != null) {
        for (ListSelectionListener l : comp.getListSelectionListeners()) {
            comp.removeListSelectionListener(l);
        }
    }
}