This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes about  JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "about  JMenu" Watch "about  JMenu" New topic
Author

about JMenu

Lei Xiaowen
Greenhorn

Joined: Jul 11, 2005
Posts: 15
Hello:
I have definite a JMenu,it have three JMenuItem.Each JMenuItem has a
Listener.
My question is how to write the code of Listener?
Constanze Michaelis
Greenhorn

Joined: Jul 28, 2004
Posts: 28
hi
which Listener do you use?

regards
Constanze
Lei Xiaowen
Greenhorn

Joined: Jul 11, 2005
Posts: 15
Hello:
//
1. JMenu menuInfo=new JMenu();
2.mainMenu.add(menuInfo);

3. JMenuItem itemShow=new JMenuItem("信息综合管理");
4. itemShow.addItemListener(ItemListener I);
5. menuInfo.add(itemShow);

at line 4 "add ItemListener "is wrong,why?
the correct code is what?
thanks a million!
Constanze Michaelis
Greenhorn

Joined: Jul 28, 2004
Posts: 28
hi
does your class implement the ItemListener?
in my menu i took the ActionListener, because MenuItems fires Action Events.
here having example what i would write


hope this helps
regards
Constanze
[ July 12, 2005: Message edited by: Constanze Michaelis ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about JMenu