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

How to remove JPopupMenu object from component  RSS feed

 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

It's really pleasure to switch again into www.javaranch.com after several days of hectic coding in EJBs.
Now I'm currently working on java swings. I faced a problem where if I right click my mouse I could able to display popup menu using JPopupMenu and if I move my mouse I should get that displayed popup to be removed.
I used MouseMotionAdapter for this and within the mouseMoved(MouseEvent e)
what can I write the code, so that my task is fulfilled.

Thanks in advance,
Narendranath.
 
Kalpith Ramamoorthi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that the JPopupMenu component works like that. If you have windows, press the right click button and move your mouse does it disappear? No so I don't think the components work like that. You could hide it or use another component... Check the Sun website!! It has useful resources on handy methods!
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Naren,
ya, we can do it.
By calling setVisible(false), in the mouseMoved(MouseEvent e) I could achieve it.

SAi.
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't we do it using
panelComponent.remove(popUpMenuComponent)
 
Sainath Veepuri
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, we can do it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!