Example usage for javax.swing DefaultListSelectionModel DefaultListSelectionModel

List of usage examples for javax.swing DefaultListSelectionModel DefaultListSelectionModel

Introduction

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

Prototype

DefaultListSelectionModel

Source Link

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 ww  w .  j  av  a  2 s  .  c o m*/
    });

    list.setSelectionModel(m);

    System.out.println(m.getMaxSelectionIndex());

    add(pane, BorderLayout.NORTH);
}

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 ww w .  j  a v a 2s.c  o  m
    });

    list.setSelectionModel(m);

    m.removeIndexInterval(1, 1);

    add(pane, BorderLayout.NORTH);
}

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());
        }//  w  ww . j a  va 2 s  .  c  om
    });

    list.setSelectionModel(m);

    System.out.println(m.toString());

    add(pane, BorderLayout.NORTH);
}

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());
        }/*  w  w  w  .  ja v a  2s.c  o  m*/
    });

    list.setSelectionModel(m);

    System.out.println(m.isSelectedIndex(0));

    add(pane, BorderLayout.NORTH);
}

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  ww w.ja v a 2  s .c  o  m*/
    });

    list.setSelectionModel(m);

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

    add(pane, BorderLayout.NORTH);
}

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 w  w w.  j a v  a  2s .  c  om*/
    });

    list.setSelectionModel(m);

    m.insertIndexInterval(1, 2, true);

    add(pane, BorderLayout.NORTH);
}

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   w  w  w. ja  v  a  2s . c om*/
    });

    list.setSelectionModel(m);

    m.setAnchorSelectionIndex(1);

    add(pane, BorderLayout.NORTH);
}

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  ww w  . j  av a 2s  .  c om
    });

    list.setSelectionModel(m);

    m.moveLeadSelectionIndex(1);

    add(pane, BorderLayout.NORTH);
}

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());
        }/*w  w w . j  ava 2  s .c o  m*/
    });

    list.setSelectionModel(m);

    System.out.println(m.isSelectionEmpty());

    add(pane, BorderLayout.NORTH);
}

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 v a  2 s  .  c  o  m
    });

    list.setSelectionModel(m);

    System.out.println(m.isLeadAnchorNotificationEnabled());

    add(pane, BorderLayout.NORTH);
}