• Post Reply Bookmark Topic Watch Topic
  • New Topic

Command Pattern

 
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
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!