Certain GUI applications need to simulate a desktop environment by allowing multiple “frames” to be displayed within a single root window. These frames look like the normal frames you’d see on a real desktop, but are not actually known to the window manager, because they are not really windows in the normal sense of the term. For some types of applications (word processors, IDEs, etc.), this can be a very powerful approach to UI design.
In this chapter, we’ll look at a collection of classes Swing provides to allow you to create this type of application in Java. At the end of the chapter, we’ll provide a large sample program that shows how to implement a variety of useful features.
Before looking at each of the classes involved in the Swing desktop/internal frame model, we’ll take a moment for an overview of how they all work together. Figure 9.1 shows the relationships between the classes we’ll be covering in this chapter.
Figure 9-1. Internal Frame and Desktop class diagram
JInternalFrame is a
container that looks much like a
JFrame. The key
difference is that internal frames can only exist within some other
JInternalFrame implements the
following three interfaces:
Each internal frame keeps a reference to an instance of the static
inner class called