| 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: 19216
|
|
|
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
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: 4164
|
|
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: 4164
|
|
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: 32668
|
|
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;)
|
 |
 |
|
|
subject: How to add MouseLsitener to JMenu
|
|
|