Example usage for javax.swing DefaultListSelectionModel insertIndexInterval

List of usage examples for javax.swing DefaultListSelectionModel insertIndexInterval

Introduction

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

Prototype

public void insertIndexInterval(int index, int length, boolean before) 

Source Link

Document

Insert length indices beginning before/after index.

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

    list.setSelectionModel(m);

    m.insertIndexInterval(1, 2, true);

    add(pane, BorderLayout.NORTH);
}