1 7 34 35 package com.sun.tools.example.debug.gui; 36 37 import javax.swing.*; 38 import javax.swing.tree.*; 39 40 public class SingleLeafTreeSelectionModel extends DefaultTreeSelectionModel { 41 42 SingleLeafTreeSelectionModel() { 43 super(); 44 selectionMode = SINGLE_TREE_SELECTION; 45 } 46 47 public void setSelectionPath(TreePath path) { 48 if(((TreeNode)(path.getLastPathComponent())).isLeaf()) { 49 super.setSelectionPath(path); 50 } 51 } 52 53 public void setSelectionPaths(TreePath[] paths) { 54 if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) { 57 super.setSelectionPaths(paths); 58 } 59 } 60 61 public void addSelectionPath(TreePath path) { 62 if(((TreeNode)(path.getLastPathComponent())).isLeaf()) { 63 super.setSelectionPath(path); 64 } 65 } 66 67 public void addSelectionPaths(TreePath[] paths) { 68 if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) { 71 super.addSelectionPaths(paths); 72 } 73 } 74 } 75 76 | Popular Tags |