简体   繁体   English

Java中的GUI架构和设计(Swing)

[英]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. 我花了最近几个小时在互联网上搜索关于如何在java中编写中型GUI的示例和想法。 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. 除了swing之外,我不知道在Java中开发GUI的任何其他方法。 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. 我还想亲自手工编写GUI,以便更容易地与我们的游戏和未来的重构集成。

We have written the entire business logic to a Tic Tac Toe game that has several features. 我们已经将整个业务逻辑编写到具有多种功能的Tic Tac Toe游戏中。 The gui needs to have several windows which can be navigated using simple buttons on the interface. gui需要有几个窗口,可以使用界面上的简单按钮进行导航。 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? 如何使用Swing构建GUI以及使用什么常规设计?

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? 在按下按钮后,我是否只使用setvisible使我的窗口显示并消失?

`re there any examples you all know of (github repos would be excellent! happy forking!) that could show me a good gui architecture/design? “那里有你们都知道的任何例子(github repos会很棒!快乐!),这可以告诉我一个好的gui架构/设计?

我认为您可以创建多个JPanel(或其扩展名),将它们放在一个容器中,并使用CardLayout并在必要时切换卡片。

还要考虑这里讨论的模型 - 视图 - 控制器模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM