Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rightclicking on components

 
Emil Karlsson
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()... )
 
Emil Karlsson
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
Now it works as I want.
/Emil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic