wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to add MouseLsitener to JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add MouseLsitener to JMenu" Watch "How to add MouseLsitener to JMenu" New topic
Author

How to add MouseLsitener to JMenu

Liana Norpunova
Greenhorn

Joined: Aug 24, 2010
Posts: 23
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

Joined: Oct 27, 2005
Posts: 19697
    
  20

This is what JMenuItem is for. Initialize it with an Action, set an Action or add an ActionListener.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
dziubut dziubucinski
Greenhorn

Joined: Sep 14, 2010
Posts: 8
Try
Liana Norpunova
Greenhorn

Joined: Aug 24, 2010
Posts: 23
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

Joined: Aug 24, 2010
Posts: 23
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

Joined: Sep 14, 2010
Posts: 8

solved?
Liana Norpunova
Greenhorn

Joined: Aug 24, 2010
Posts: 23
Oh, thank you so much, dear!!! it works perfectly!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4572
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4572
    
    5

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

Joined: Oct 13, 2005
Posts: 39076
    
  23
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

Joined: Sep 14, 2010
Posts: 8
Ok true, my bad. She should learn java basics before. No more free code without comment anymore;)
 
GeeCON Prague 2014
 
subject: How to add MouseLsitener to JMenu