Scroll panes are a type of viewport that facilitates scrolling by presenting a vertical or horizontal scroll bar that the user can drag to access the obscured parts of the view. They are often used to wrap data-driven components containing a lot of items (such as a TableView displaying a long list of database query results), or to wrap long forms.
The following example demonstrates the use of a scroll pane to display a large image:
The BXML source for this example is shown below:
<Window title="Scroll Panes" maximized="true" xmlns:bxml="http://pivot.apache.org/bxml" xmlns:navigation="org.apache.pivot.tutorials.navigation" xmlns="org.apache.pivot.wtk"> <Border styles="{color:10}"> <ScrollPane> <ImageView image="/org/apache/pivot/tutorials/IMG_1147.jpg" tooltipText="Pemaquid Point Lighthouse, Bristol ME"/> <columnHeader> <navigation:Ruler orientation="horizontal"/> </columnHeader> <rowHeader> <navigation:Ruler orientation="vertical"/> </rowHeader> </ScrollPane> </Border> </Window>
In addition to the view (an ImageView, in this example), scroll panes also support the concept of row and column "header" components. A column header remains fixed vertically at the top of the scroll pane but scrolls horizontally with the view, and a row header is fixed horizontally at the left of the scroll pane but scrolls vertically with the view.
The column header is commonly used to display a TableViewHeader component for a TableView, discussed in more detail in the Table Views section. In this example, the header components are set to instances of a custom Ruler component that displays a tick mark every 5 pixels.
Since this example contains no logic, there is no associated Java source.
Next: Panoramas