Normand Briere
2019-06-25 ecff440ceef3ad352aa64cedbb913107ec4863a5
cTree.java
....@@ -2,17 +2,29 @@
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
+ popup.show((JComponent) e.getSource(), e.getX(), e.getY());
25
+ }
26
+ }
27
+ });
1628 }
1729
1830 /*
....@@ -46,8 +58,17 @@
4658 Rectangle inner = getParent().getBounds();
4759 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);
4860 }
49
-
50
- // Use this method if you want to see the boundaries of the
61
+//@Override
62
+//public void mouseClicked(java.awt.event.MouseEvent e) {
63
+//
64
+// if (SwingUtilities.isRightMouseButton(e)) {
65
+//
66
+// int row = getClosestRowForLocation(e.getX(), e.getY());
67
+// setSelectionRow(row);
68
+// popupMenu.show(e.getComponent(), e.getX(), e.getY());
69
+// }
70
+//}
71
+// Use this method if you want to see the boundaries of the
5172 // autoscroll active region
5273
5374 /* bug
....@@ -62,4 +83,3 @@
6283 /**/
6384 }
6485 /**/
65
-