简体   繁体   English

在制作MDI时,我应该使用JDesktopPane或JFrame

[英]When making an MDI should I use JDesktopPane or JFrame

It appears as if there is very little use of JDesktopPane but it doesn't appear to be deprecated. 看起来似乎很少使用JDesktopPane,但它似乎没有被弃用。 Are they any advantages of using JDesktopPane instead JFrame? 使用JDesktopPane代替JFrame有什么优势吗? I mainly plan on putting a few JInternalFrames into it. 我主要计划将几个JInternalFrames放入其中。

EDIT: I didn't realize that a JDesktopPane more fills the role of a Panel than a frame. 编辑:我没有意识到JDesktopPane更多地填充Panel的角色而不是框架。

A JDesktopPane should sit inside a JFrame's contentPane instead of a Jpanel. JDesktopPane应该位于JFrame的contentPane而不是Jpanel中。 Thanks for the answers fellows! 谢谢你的答案!

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. 我在需要多个框架的应用程序中经常使用JDesktopPane,但我不想阻塞用户任务栏,并且希望更好地控制框架。 Yes, it is used less than JFrame, but I don't think it will be deprecated (at least not anytime soon). 是的,它的使用少于JFrame,但我认为它不会被弃用(至少不会很快)。

JDesktopPane and JInternalFrame is Swings implementation of a MDI application. JDesktopPane和JInternalFrame是MDI应用程序的Swings实现。 All internal frames are managed by the desktop pane, not the OS. 所有内部框架均由桌面窗格管理,而不是操作系统。

In general an application should only ever have a single JFrame. 通常,应用程序应该只有一个JFrame。 If you need other windows then use JDialogs. 如果您需要其他窗口,请使用JDialogs。

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

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