6.6.2. Tabbed Panes

Tabbed panes are a familiar user interface device to break up a complex dialog box into subsets of related options. You can also use tabs to let a user flip through a set of documents or images (see Figure 6.45). That is what we do in our sample program.

Image

Figure 6.45. A tabbed pane

To create a tabbed pane, first construct a JTabbedPane object, then add tabs to it.

JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(title, icon, component);

The last parameter of the addTab method has type Component. To add multiple components into the same tab, first pack them up in a container, such as a JPanel.

The icon is optional; ...

Get Core Java® Volume II—Advanced Features, Ninth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.