From 67134f5389b08ee7a1704755238c856f2e1983d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 18 Jan 2019 12:12:47 +0100 Subject: [PATCH] Make the JTree have a single selection model. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/RegionView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/RegionView.java b/src/RegionView.java index d44cd04..17a2949 100644 --- a/src/RegionView.java +++ b/src/RegionView.java @@ -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; + } } -- 2.34.1