aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes AbstractAction Not Working With JMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "AbstractAction Not Working With JMenu" Watch "AbstractAction Not Working With JMenu" New topic
Author

AbstractAction Not Working With JMenu

Suresh Bansal
Ranch Hand

Joined: Jul 23, 2001
Posts: 91
Hello Friends,
I am using jdk 1.4 and AbstractAction to link button and menu to the same action class.
While buttons are working fine, the menu is giving ClassCastException:String when i run my program
My code is something like
JMenu file = new JMenu("File");
Action action = new AbstractAction("New") {
public void actionPerformed(ActionEvent e) {
System.out.println("Hello ...");
}
};
JMenuItem book = file.add(action);
JMenuItem search = file.add(new SearchAction("Search"));
mBar.add(file);
While action is working properly with menu, SearchAction is not.
Search action declared like - public class SearchAction extends AbstractAction
If any body could give pointers to what i might be doing wrong ... It would be a great help ...
Thanks,
Suresh


Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AbstractAction Not Working With JMenu