Java Reference
In-Depth Information
that comes with the JDK 1.2 version of the Swing classes. (This version is more appropriate
than the current one for demonstrating the features of
JTabbedPane
described in this section.)
Figure 11-10.
Sample JTabbedPane screen
To help the
JTabbedPane
manage which
Component
(tab) is selected, the model for the
container is an implementation of the
SingleSelectionModel
interface or, more precisely, a
DefaultSingleSelectionModel
instance. (
SingleSelectionModel
and
DefaultSingleSelectionModel
were described with the menuing classes in Chapter 6.)
Creating a JTabbedPane
There are only three constructors for the
JTabbedPane
:
public JTabbedPane()
JTabbedPane tabbedPane = new JTabbedPane();
public JTabbedPane(int tabPlacement)
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT);
public JTabbedPane(int tabPlacement, int tabLayoutPolicy)
JTabbedPane tabbedPane =
new JTabbedPane(JTabbedPane.RIGHT, JTabbedPane.SCROLL_TAB_LAYOUT);