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.
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 ...
Get Java Swing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.