What is the best way to implement a global default context menu for a Swing app that has the Windows-standard cut/copy/paste/etc. popup menu for things like JTextField? Tim Boudreau suggested installing a custom UI delegate in this javalobby thread but that was written with Java 5 in mind, so I'm wondering if there's a better way today.
Are there plans to add this behavior in a future version of Swing itself?
Good timing. My blog entry for tomorrow was going to be about using Global Event Listeners. The simple answer is to use an AWTEventListener (instead of a custom EventQueue) to listen for MouseEvents and to then check the mouse event to see if it is a popup trigger.
I'll post the link to the entry tomorrow afternoon (EDT) when I get it published.
Then you can decide which approach is better.
You can now check out the Global Event Listeners entry for a really simple example of using an AWTEventListener.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With