This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • 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