A scroll pane is a component that presents a rectangular area in which a component
may be viewed. Horizontal and/ or vertical scroll bars may be provided if necessary,
Scroll panes are implemented in Swing by the j Scrofulous class, which extends J Compunction. Some of its constructors arc shown here: The following example illustrates a scroll pane. First, the content pane of the JApplet object 15 obtained and a border layout is assigned as its layout manager. Next, a Jl’ancl object Is treated and four hundred buttons are added to it, arranged into twenty columns. The panel is then added to a scroll pane, and the scroll pane is added to the content pane. This causes vertical and horizontal scroll bars to appear. You can use the scroll bars to scroll the buttons into view.
A tree is a component that presents a hierarchical view of data. A user has the ability to expand or collapse individual sub frees in this display. Trees are implemented in Swing by the Tree class, which extends Component. Some of its constructors arc shown here:
JTrec(Object obj[ ])
The first form creates a tree-in whi-ch each clement of the hush table lit is a child node. Each element of the array obj is a child node in the second form. The tree node III is the root of the tree in the third form. Finally, the last form uses the clements of vector ~,as child nodes. A [Tree object generates events when a node is expanded or collapsed. The addTrceExpansionListencr( ) and rcmoveTrceExpansionListencr( ) methods allow listeners to register and unregistered for these notifications. The signatures of these methods arc shown here: void addTreeExpansionListener TreeExpansionListencr Id
void TreeExpansionListencr(TrceExpansionListencr tel)