Example usage for javax.swing DefaultListSelectionModel getListeners

List of usage examples for javax.swing DefaultListSelectionModel getListeners

Introduction

In this page you can find the example usage for javax.swing DefaultListSelectionModel getListeners.

Prototype

public <T extends EventListener> T[] getListeners(Class<T> listenerType) 

Source Link

Document

Returns an array of all the objects currently registered as FooListeners upon this model.

Usage

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    DefaultListSelectionModel m = new DefaultListSelectionModel();

    m.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.toString());
        }/*from  www .  j a  va 2  s  . c  om*/
    });

    list.setSelectionModel(m);

    ListSelectionListener[] lsls = (ListSelectionListener[]) (m.getListeners(ListSelectionListener.class));

    add(pane, BorderLayout.NORTH);
}