Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Command Pattern  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I have a problem how to deal with Command pattern when two components are doing the same thing (JMenuItem and JButton). Having the same code twice in both command classes doesn't sound very good. Do you have any advice how to solve this problem?
Jukka
 
Mike Birken
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply have each listener call the same method and put the code you would normally put in both listeners into that single method. BTW, what you are describing is not the Command Design Pattern.
- Mike
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!