0

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!

davidahines
  • 3,976
  • 16
  • 53
  • 87

2 Answers2

1

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

jzd
  • 23,473
  • 9
  • 54
  • 76
1

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.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • What I'm asking though is what should I use for the container for JInternal frames? JDesktopPane or JFrame? I don't really need any other windows aside from the one storing the JInternalFrames – davidahines Nov 23 '10 at 21:12
  • 2
    As I said the two where designed to be used together. Why reinvent the wheel and try to make a JFrame support the functionality of a desktop pane. Did you even try to add multiple internal frames to a JFrame? Did it work? Did you try the Swing tutorial on using internal frames to see how they work in a desktop pane? – camickr Nov 23 '10 at 21:23
  • I did. Adding multiple internal frames to a JFrame works and they act similar. The Actions like iconifying, maximizing, etc don't work but the frames still sit inside of the JFrame or JPanel fine. I tried the demo but I found it didn't make it clear that it wasn't a top level container. – davidahines Dec 07 '10 at 22:06