This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes two jpopupmenus associates with two differents components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "two jpopupmenus associates with two differents components" Watch "two jpopupmenus associates with two differents components" New topic
Author

two jpopupmenus associates with two differents components

nic den
Greenhorn

Joined: Jun 07, 2009
Posts: 7
hi atm i can show one jpopupmenu for one component

but i would like to know (whats the function or a sample code will do)
how to assciate two differents jpopupmenus with two differents components
like one jpopupmenu will be associate with the jtextpane and the other one with the jtextfield

thank for the help in advance

i search for this but i found nothing good yet
i thought that the setInheritsPopup funtion would do the job but thats not what im looking for
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> hi atm i can show one jpopupmenu for one component

if you're using a mouseListener to trigger your popup.
simple use the event.getSource() to get the component,
then instanceof to see if a JTextPane of a JTextField
nic den
Greenhorn

Joined: Jun 07, 2009
Posts: 7
thank for the reply

yeah i should have think about this but i didnt lol
im use to do event.getsource() with actionlistener but i never done it with a mouselistener()
now its more clear how to do this

thank again michael

here is the solution :

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: two jpopupmenus associates with two differents components
 
Similar Threads
How add JLabels as headers for JPopupMenu's menuitem sections?
J2EE applications
web aplication inside a portlet
JPopupMenus
Comunicate two Applications in one machine in Java