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 WTKX source for this example is shown below:
<Window title="Scroll Panes" maximized="true" xmlns:wtkx="http://pivot.apache.org/wtkx" xmlns="org.apache.pivot.wtk"> <content> <Border styles="{padding:0, color:10}"> <content> <ScrollPane> <view> <ImageView image="org/apache/pivot/tutorials/IMG_1147.jpg" tooltipText="Pemaquid Point Lighthouse, Bristol ME"/> </view> </ScrollPane> </content> </Border> </content> </Window>
The Java source is as follows:
package org.apache.pivot.tutorials.navigation; import org.apache.pivot.collections.Map; import org.apache.pivot.wtk.Application; import org.apache.pivot.wtk.DesktopApplicationContext; import org.apache.pivot.wtk.Display; import org.apache.pivot.wtk.Window; import org.apache.pivot.wtkx.WTKXSerializer; public class ScrollPanes implements Application { private Window window = null; public void startup(Display display, Map<String, String> properties) throws Exception { WTKXSerializer wtkxSerializer = new WTKXSerializer(); window = (Window)wtkxSerializer.readObject(this, "scroll_panes.wtkx"); window.open(display); } public boolean shutdown(boolean optional) { if (window != null) { window.close(); } return false; } public void suspend() { } public void resume() { } public static void main(String[] args) { DesktopApplicationContext.main(ScrollPanes.class, args); } }
In addition to the view component, scroll panes also support row and column header components. The column header remains fixed vertically at the top of the scroll pane but scrolls horizontally with the view, and the row header is fixed horizontally at the left of the scroll pane but scrolls vertically with the view. An example of a column header is shown in the Table Views section.
Next: Panoramas