Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add MouseLsitener to JMenu

 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Does anybody know how to add MouseListener to JMenu? I have a working code that implements MenuListener, however it is not exactly what I need, because the procedure "createBaseRight" is executed after selecting (NOT CLICKING) JMenu: home. I've tried MouseListener, however it didn't work here. Any suggestions?

 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what JMenuItem is for. Initialize it with an Action, set an Action or add an ActionListener.
 
dziubut dziubucinski
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

yeah, I know how to add Listener to JMenuItem. However, the problem is that I need Listener for JMenu

I've tried ActionListener, however it doesn't work...simply no reaction...

Well, if you would tell me that it is impossible to add MouseListener to JMenu, then I will try to find another solution.
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I've tried to implement MouseListener for JMenu, then I've got the message "Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet." Does it mean that it is absolutely impossible to solve this problem?
 
dziubut dziubucinski
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

solved?
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, thank you so much, dear!!! it works perfectly!
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liana Norpunova wrote:When I've tried to implement MouseListener for JMenu, then I've got the message "Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet." Does it mean that it is absolutely impossible to solve this problem?

You need to learn Java before, not after, you start using the automatic code generation features of your IDE.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dziubut dziubucinski wrote:
solved?

Posting code ready for Ctrl-C Ctrl-V doesn't help anyone to learn. Do you plan to be around the next time the OP's IDE spews out code s/he still hasn't learned to read and understand?

The "Not supported yet" is a dead giveaway.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49411
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote: . . . The "Not supported yet" is a dead giveaway.
Agree. It tells me Liana Norpunova uses NetBeans and the //TODO tells me dziubut dziubucinski uses Eclipse

And welcome to the Ranch, dziubut dziubucinski
 
dziubut dziubucinski
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok true, my bad. She should learn java basics before. No more free code without comment anymore;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic