• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add MouseLsitener to JMenu

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what JMenuItem is for. Initialize it with an Action, set an Action or add an ActionListener.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

solved?
 
Liana Norpunova
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, thank you so much, dear!!! it works perfectly!
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok true, my bad. She should learn java basics before. No more free code without comment anymore;)
 
reply
    Bookmark Topic Watch Topic
  • New Topic