O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Specialty Panes and Layout Managers

With all the new Swing components, you might expect to see a few new layout managers to help place them, and you wouldn’t be disappointed. The Swing package includes several new layout managers. However, most of these managers are meant for use with specific containers—JScrollPane has its own ScrollPaneLayout manager, for example. The Swing package also includes several new convenience containers that handle varied things such as scrolling and tabs. We’ll be taking a close look at these containers and their associated layout managers in this chapter. Figure 11.1 shows the class hierarchy of Swing’s specialty panes and layout managers.

Swing’s specialty panes and layout managers

Figure 11-1. Swing’s specialty panes and layout managers

The JSplitPane Class

The JSplitPane component allows you to place two (and only two) components side by side in a single pane. You can separate the pane horizontally or vertically, and the user can adjust this separator graphically at runtime. You have probably seen such a split pane approach in things like a file chooser or a news reader. The top or left side holds the list of directories or news subject lines, while the bottom side (or right side) contains the files or body of the currently selected directory or article. To get started, Figure 11.2 shows a simple split pane example that shows two text areas and horizontal split. You can adjust the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required