Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

GUI design

 
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
 
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.
 
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).
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic