Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenuItem on JPopUpMenu - how to setSelected ?  RSS feed

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I have a JPopUpMenu with a number of JMenuItem's on it. When JMenuItems appear in the normal way on JMenu's on JMenuBars, when you move the mouse over them they look selected - ie, blue with white text (on the Windows L&F).

How can I accomplish this with JMenuItems on a JPopUpMenu? I have tried to put a MouseListener on the JMenuItem but it does not seem to work.

Example: This code is for a component that extends JMenuItem and implements MouseListener.


Any advice would be great.

Many kind regards,
Rachel
 
Basanth P Rangadhol
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir,

i have used JPopupMenu in a simple program, wherein the JMenuItem(s) get selected(highlighted) as mouse is moved over.. i am sure that the action what you want is default action of any popupmenu... (since i have used a simple popupmenu with two JMenuItems)...

i do not know how this helps you...
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rachel,

i got the same problem with PopuMenu. One solution i used for that is setting the colors in mouseEntered and Exited methods.



Hope This Helps.
All The Best
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! It works like a charm.

Cheers,
Rachel
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!