List of usage examples for javax.swing JTree setSelectionModel
@BeanProperty(description = "The tree's selection model.") public void setSelectionModel(TreeSelectionModel selectionModel)
From source file:Main.java
public static void main(String[] args) { final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); fillTree(root, 5, "Tree label"); final DefaultTreeModel model = new DefaultTreeModel(root); JTree tree = new JTree(model); tree.setSelectionModel(new MyTreeSelectionModel()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(tree)); f.setSize(400, 600);//from w ww.j a va 2 s.c o m f.setVisible(true); }