制作 MDI 时我应该使用 JDesktopPane 还是 JFrame

发布于 2024-10-04 05:22:17 字数 217 浏览 1 评论 0原文

JDesktopPane 的使用似乎很少,但它似乎并未被弃用。使用 JDesktopPane 代替 JFrame 有什么优点吗?我主要打算放几个JInternalFrame进去。

编辑:我没有意识到 JDesktopPane 更多地扮演了面板而不是框架的角色。

JDesktopPane 应该位于 JFrame 的 contentPane 而不是 Jpanel 内。谢谢各位朋友的解答!

It appears as if there is very little use of JDesktopPane but it doesn't appear to be deprecated. Are they any advantages of using JDesktopPane instead JFrame? I mainly plan on putting a few JInternalFrames into it.

EDIT: I didn't realize that a JDesktopPane more fills the role of a Panel than a frame.

A JDesktopPane should sit inside a JFrame's contentPane instead of a Jpanel. Thanks for the answers fellows!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盛装女皇 2024-10-11 05:22:17

由于目的不同,两者很难进行比较。

我经常在需要多个框架的应用程序中使用 JDesktopPane,但我不想阻塞用户任务栏并希望对框架进行更精细的控制。是的,它的使用量比 JFrame 少,但我认为它不会被弃用(至少不会很快)。

It is hard to make a comparison between the two since they have different purposes.

I use JDesktopPane frequently in applications that need several frames but I don't want to clog up the users task bar and want a finer control of the frame. Yes, it is used less than JFrame, but I don't think it will be deprecated (at least not anytime soon).

没有伤那来痛 2024-10-11 05:22:17

JDesktopPane 和 JInternalFrame 是 MDI 应用程序的 Swings 实现。所有内部框架均由桌面窗格管理,而不是操作系统。

一般来说,应用程序应该只具有一个 JFrame。如果您需要其他窗口,请使用 JDialogs。

JDesktopPane and JInternalFrame is Swings implementation of a MDI application. All internal frames are managed by the desktop pane, not the OS.

In general an application should only ever have a single JFrame. If you need other windows then use JDialogs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文