From: Jérôme Benoit Date: Fri, 18 Jan 2019 11:12:47 +0000 (+0100) Subject: Make the JTree have a single selection model. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=67134f5389b08ee7a1704755238c856f2e1983d5;p=Persons_Comparator.git Make the JTree have a single selection model. Signed-off-by: Jérôme Benoit --- 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; + } }