aspose file tools *
The moose likes Swing / AWT / SWT and the fly likes Rightclicking on components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Rightclicking on components" Watch "Rightclicking on components" New topic
Author

Rightclicking on components

Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Hi,
I have made a class that extend a JButton, now I would like to show a popup when I make a rightclick over the component!
The same procedure works perfect with JLabel!
Why does it not work with JButton?
/Emil Karlsson
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
some code of yours would be helpful. especially, where you catch the popup events for your JLabel and for your JButton.
are you checking whether the mouse event is a popup trigger? (event.isPopupTrigger())
chantal
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I don't know how to do it with your extended button, since you didn't post the code... but here's how you can add a popup menu to a normal JButton...



( Chantal - for some weird reason isPopupTrigger() wouldn't work... I had to use isMetaDown()... )


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Emil Karlsson
Ranch Hand

Joined: May 23, 2002
Posts: 63
Thanks a lot.
Now it works as I want.
/Emil
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Rightclicking on components