GUI Architecture and Design in Java (Swing)
I have spent the last several hours scouring the internet looking for examples and ideas on how to write a medium sized GUI in java. I know a little about swing but that is all. I don't know of any other way to develop a GUI in Java besides swing. If you know of a different way that would be good too. I also want to hand-write the GUI myself to allow for easier integration with our game and future refactoring.
We have written the entire business logic to a Tic Tac Toe game that has several features. The gui needs to have several windows which can be navigated using simple buttons on the interface. A very crude and water-downed version of what I am looking to do can be seen below:
The Heart of my question is this:
How do I architect the GUI using Swing and what general design is used?
and some follow-up questions: Is there a class for every window? Do I just use setvisible to make my windows appear and disappear after the buttons are pressed?
`re there any examples you all know of (github repos would be excellent! happy forking!) that could show me a good gui architecture/design?
Answers
I think you can create multiple JPanels (or their extensions) place them in one container with CardLayout and switch cards when necessary.
Also consider the Model–View–Controller pattern, discussed here.