Is there a way to globally make right click also select the element that you right click on? From what I understand this has been a bug in Swing for a long time likely to never be fixed because at this point applications depend on it. Any advice on doing this on a global scale? Perhaps on the L&F?
views:
562answers:
1
+1
A:
Using the Glass Pane will do the trick.
Here's a tutorial on how to use the glass pane to get the right click button and redispatch it to the right component.
As the glass pane is not a solution in this case, I suggest you take a look at the Toolkit class. Specificaly the addAWTEventListener method. You can add a global event listener with it. To add a mouse event listener:
Toolkit.getDefaultToolkit().
addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
Cheers
Marcio Aguiar
2008-09-12 02:09:23
Glass pane to the rescue again.
Allain Lalonde
2008-09-12 13:25:07
A Glass Pane does not work for my case, but maybe a good answer for someone else.
drye
2008-09-12 17:39:11
Why not? When you say "element" you mean any Swing component? Or elements in a tree or list?
Marcio Aguiar
2008-09-12 20:14:10
drye
2008-09-13 00:14:31
Updated my answer
Marcio Aguiar
2008-09-13 22:10:26
The toolkit looks like it might be the solution. I will update after I get back to this issue.
drye
2008-09-15 14:47:59