File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "AbstractAction Not Working With JMenu" Watch "AbstractAction Not Working With JMenu" New topic

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"));
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 ...

Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
I agree. Here's the link:
subject: AbstractAction Not Working With JMenu
It's not a secret anymore!