This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rightclicking on components
 
Similar Threads
What is MVC
Processing different ActionEvents in actionPerformed()
Not able to access an Array of buttons from another class
How to set the color of a button and toolbar ?
Feel Like I Am Starting Over