aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JMenu" Watch "JMenu" New topic
Author

JMenu

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!
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
The notation in the method signature addItemListener(ItemListener I) is a way of saying that the argument I must be of type ItemListener. For line 4 you want to put a reference to/or the actual listener in as the argument. We have lots of options for this, such as

You would use the method signature as given
public void addItemListener(ItemListener I) {
...
}
if you wanted to override it inside a class that extends JMenuItem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMenu