Example usage for javax.swing DefaultListSelectionModel removeSelectionInterval

List of usage examples for javax.swing DefaultListSelectionModel removeSelectionInterval

Introduction

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

Prototype

public void removeSelectionInterval(int index0, int index1) 

Source Link

Document

Changes the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.

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

    list.setSelectionModel(m);

    m.removeSelectionInterval(1, 1);

    add(pane, BorderLayout.NORTH);
}