JFrame在另一个JFrame中 [英] JFrame inside another JFrame

查看:146
本文介绍了JFrame在另一个JFrame中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一盘棋。
我写过3节课。如果是游戏,
1st。 (棋盘,棋子等)
另一个是菜单。 (按钮,如新的,开放的,设定的时间)



他们都使用JFrame。



我想要把上面提到的两个类都放到第三课。例如,游戏窗口位于左侧,菜单位于右侧。
第三类也会显示JFrame的整个应用程序。



怎么做?

解决方案

您不能将一个JFrame放入另一个JFrame中。你有几个设计选择。您可以将JFrame更改为JPanel。这可能是最容易的改变。另一方面,您可以使用内部框架代替。


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)

Both of them use 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.

How to do that?

解决方案

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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆