This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI design

 
Maksym Odintsov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. I implemented my GUI in such way that I have the same JFrame for the server, standalone client, and network client. So depending on the mode of the program this JFrame chooses to show some fields and labels or not to show them. I read something simalar in the Andrews book, he used common panel for all modes.
But I'm using not the panel, but a frame and this means that inside the ActionListener of the start button I use case operator to determine the mode of the program and then start server or open the main window etc.
So How do you think is it a bad design and it's better to implement 3 separate frames(though they will use a lot of similar JTextFields and labels ... ) for server, client and network client with 3 separate ActionListeners
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I had was an abstract config view (which contained all common code) with 3 subclasses, and used the State design pattern for instantiating one of these subclasses.
Both my config and client views were directly inheriting from JFrame.
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Maksym:

What I used was only one frame and three panels, but on this three panels I had common code so I used the Template Method Pattern to put all the common code in an abstrac class and I just set the code that changed in subclasses. I used Panels because I believe they are easier to change than frames.

By the way I do not mean changing code or maintenance, I tried to say change from one panel to another (like from the configuration panel to the main panel that contains the search criteria and all that stuff).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic