Java Reference
In-Depth Information
64.
public static void main(String[] args)
65.
{
66.
SplitPaneFrame spf = new SplitPaneFrame();
67.
spf.showIt("Split-Panes",200,200);
68.
}
69.
}
16.7
Tabbed panes
Split panes are used to display two documents and to vary the view of them. A
different Swing component should be considered if an application generates a
large number of documents. In this section we introduce tabbed panes . They can
administer a large number of documents, only one of which is visible at a time.
The user can rapidly switch between them. One can imagine a tabbed pane as a
stack of papers each of which contains some textual or pictorial information. In
addition every page has a tab . Only the topmost page is visible. Another page can
become the topmost one by grabbing its tab, pulling it out and putting it on top of
the stack. See Figure 16.10 for an example.
In Swing, this mechanism is implemented in class JTabbedPane .Atabbed pane
is initially empty, i.e. it contains no pages. Then components are added and each of
them becomes a new page. When adding a component, the text for the tab should
be provided. The tabs are arranged from left to right (or from top to bottom) in the
order in which the components are added. Selecting a component as the topmost
one does not change the order of the tabs. This order is reflected in the so-called
indices. Every page has an index ( index ). A tabbed pane with n pages has indices
0
1. The index of the component with the left most (topmost) tab is 0.
The indices can, for example, be used to remove a component or to insert a new
one at a certain position.
,
1
,...,
n
Figure 16.10 The third page of the example application for tabbed panes
Search WWH ::




Custom Search