Make the JTree have a single selection model.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 18 Jan 2019 11:12:47 +0000 (12:12 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 18 Jan 2019 11:12:47 +0000 (12:12 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/RegionView.java

index d44cd0494f9f10dd063eb4b59ec09ad4d230691d..17a294908f6933a8915d19a5da672a923c9a2c51 100644 (file)
@@ -1,5 +1,6 @@
 import javax.swing.*;
 import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeSelectionModel;
 import java.util.ListIterator;
 
 public class RegionView extends JPanel {
@@ -51,6 +52,7 @@ public class RegionView extends JPanel {
         }
         sortTree(top);
         tree = new JTree(top);
+        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
         add(new JScrollPane(tree));
     }
 
@@ -80,4 +82,8 @@ public class RegionView extends JPanel {
     public void setRegionObj(Region regionObj) {
         this.regionObj = regionObj;
     }
+
+    public Region getRegionObj() {
+        return regionObj;
+    }
 }