简体   繁体   中英

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. 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!

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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