How can I create a multiple document interface(MDI) application in Java?

Sandip Chitale

Well the Multiple Document Interface is different things to different people. If you are talking about visual aspects of MDI i.e. just the set of child windows(MDICHildWindows) that stay inside the main application window. That can be achieved simply by using the following classes from Swing -


Mind you though - this still does not behave exactly like M*Soft's implementation of MDI. The differences are as follows -

  1. The maximized JInternalFrames still have the TitleBar and other buttons like minimize/restore/close do not merge into main application's menubar.
  2. Multiple layers are supported in the JDesktopPane (being a subclass of JLayeredPane).
  3. Automatic switching of the MenuBar based on which child window has the focus is not supplied. You have to manage it.

If you are talking about the full blown notion of MDI i.e.

DocumentFactory or ModelFactory
Document or Model
Frame and MDIChildWindow

You will have to do it yourselves.