• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AbstractAction Not Working With JMenu

 
Suresh Bansal
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic