Example usage for javax.swing DefaultListSelectionModel clone

List of usage examples for javax.swing DefaultListSelectionModel clone

Introduction

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

Prototype

public Object clone() throws CloneNotSupportedException 

Source Link

Document

Returns a clone of this selection model with the same selection.

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.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m.setLeadAnchorNotificationEnabled(false);
    list.setSelectionModel(m);/*from  w  w w . ja  v  a2s .  c om*/

    try {
        DefaultListSelectionModel mClone = (DefaultListSelectionModel) m.clone();
    } catch (CloneNotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    add(pane, BorderLayout.NORTH);
}