Normand Briere
2019-08-06 b3ae4e889872ca0b9ca76f1d17b2f0b961226729
cTree.java
....@@ -2,17 +2,33 @@
22 /**/
33 import java.awt.*;
44 import java.awt.dnd.*;
5
-import javax.swing.JTree;
6
-import javax.swing.tree.TreeModel;
5
+import javax.swing.*;
6
+import javax.swing.tree.*;
7
+import java.awt.event.*;
78
89 class cTree extends JTree implements Autoscroll //, DragGestureListener
910 {
11
+ JPopupMenu popup = new JPopupMenu();
1012
11
- public cTree(TreeModel newModel)
13
+ public cTree() // TreeModel newModel)
1214 {
13
- super(newModel);
14
-
15
+ //super(newModel);
16
+
1517 //setRootVisible(false);
18
+
19
+ addMouseListener(new MouseAdapter()
20
+ {
21
+ public void mousePressed(MouseEvent e)
22
+ {
23
+ if (e.isPopupTrigger())
24
+ {
25
+ int row = getClosestRowForLocation(e.getX(), e.getY());
26
+ if (!isRowSelected(row))
27
+ setSelectionRow(row);
28
+ popup.show((JComponent) e.getSource(), e.getX(), e.getY());
29
+ }
30
+ }
31
+ });
1632 }
1733
1834 /*
....@@ -46,8 +62,17 @@
4662 Rectangle inner = getParent().getBounds();
4763 return new Insets(inner.y - outer.y + margin, inner.x - outer.x + margin, outer.height - inner.height - inner.y + outer.y + margin, outer.width - inner.width - inner.x + outer.x + margin);
4864 }
49
-
50
- // Use this method if you want to see the boundaries of the
65
+//@Override
66
+//public void mouseClicked(java.awt.event.MouseEvent e) {
67
+//
68
+// if (SwingUtilities.isRightMouseButton(e)) {
69
+//
70
+// int row = getClosestRowForLocation(e.getX(), e.getY());
71
+// setSelectionRow(row);
72
+// popupMenu.show(e.getComponent(), e.getX(), e.getY());
73
+// }
74
+//}
75
+// Use this method if you want to see the boundaries of the
5176 // autoscroll active region
5277
5378 /* bug
....@@ -62,4 +87,3 @@
6287 /**/
6388 }
6489 /**/
65
-