另一个 JFrame 中的 JFrame

2022-01-24 00:00:00 user-interface java swing 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.

相关文章