Example usage for javax.swing.tree TreeSelectionModel CONTIGUOUS_TREE_SELECTION

List of usage examples for javax.swing.tree TreeSelectionModel CONTIGUOUS_TREE_SELECTION

Introduction

In this page you can find the example usage for javax.swing.tree TreeSelectionModel CONTIGUOUS_TREE_SELECTION.

Prototype

int CONTIGUOUS_TREE_SELECTION

To view the source code for javax.swing.tree TreeSelectionModel CONTIGUOUS_TREE_SELECTION.

Click Source Link

Document

Selection can only be contiguous.

Usage

From source file:TreeSelectionOption.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);/*from w w  w. j  a  v a 2 s .c om*/
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}