MDI Applications: Using JDesktopPane and JInternalFrames


Swing makes MDI (Multiple Document Interface - windows within windows) easy to implement. The model is like traditional computer windowing systems. In a windowing system, you have a desktop with windows on it. With the Swing MDI, you use a JDesktopPane with JInternalFrames on it. The user can position the JInternalFrames like windows on a traditional desktop as well as resize, close, and minimize them. Forte for Java, Community Edition lets you lay out and define all of this interactively.

You typically start with a JFrame and then add a JDesktopPane to it. To add JInternalFrames, select them from the Swing (Other) tab of the Component Palette and click on the JDesktopPane. This adds internal frames with fixed structure. Alternatively, you can create separate forms for the types of frames you want, and then (construct and) add these in code to the desktop pane, thus giving you more flexibility.

You can add other components to the JDesktopPane such as a JTable or JSlider. However, these have their standard properties, and users can't manipulate them in the same way that they can manipulate a JInternalFrame containing those components.


Contents Prev Next Index