JFrame inside another JFrame(另一个 JFrame 中的 JFrame)
问题描述
我有一盘棋.我写了3节课.第一个如果是游戏.(棋盘、棋子等)另一个是菜单.(新建、打开、设置时间等按钮)
I have a game of chess. I have written 3 classes. 1st if for game. (chessboard, pieces, and so on) And another one is for menu. (buttons like new, open, set time)
他们都使用 JFrame.
Both of them use JFrame.
我想把上面提到的两个类都放到第三类.例如,游戏窗口在左侧,菜单在右侧.第三个类也将通过 JFrame 显示整个应用程序.
I would like to put both classes mentioned above into the 3rd class. For example the Game window would be on the left, and the menu on the right. The third class would also show the whole app by JFrame.
怎么做?
推荐答案
你不能把一个 JFrame 放在另一个里面.您在这里有几个设计选择.您可以将 JFrames 更改为 JPanels.这可能是最简单的改变.另一方面,您可以考虑改用 内部框架.
You can't put one JFrame inside another. You have a couple of design choices here. You can change your JFrames to JPanels. This is probably the easiest change. On the other hand, you can look at using Internal Frames instead.
这篇关于另一个 JFrame 中的 JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:另一个 JFrame 中的 JFrame
基础教程推荐
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
