buoy.widget

Class BScrollPane


public class BScrollPane
extends WidgetContainer

A BScrollPane is a WidgetContainer with up to five children: an arbitrary "content" Widget that fills most of the BScrollPane, optional "row header" and "column header" Widgets along the left and top edges, respectively, and optional BScrollBars along the right and bottom edges. It displays only a portion of the content, row header, and column header Widgets, and allows the user to scroll through them by means of the two BScrollBars.

If the BScrollPane does not have a horizontal and/or vertical scrollbar, then by default it will force the corresponding dimension of the content and header Widgets to exactly match the size of the visible area. For example, if the content is a BTextArea with word wrap enabled, you would normally only have a vertical scrollbar. The width of the BTextArea should then be forced to exactly match the width of the visible area, so that words will wrap at the correct place. You can override this behavior by calling setForceWidth() and setForceHeight(). For example, you might want to control the scroll position through some external means, in which case the BScrollPane would not provide scrollbars but should still allow the content Widget to be its preferred size.

Author:
Peter Eastman

Nested Class Summary

static class
BScrollPane.ScrollbarPolicy
This inner class represents a scrollbar policy for the horizontal or vertical scrollbar.

Field Summary

static BScrollPane.ScrollbarPolicy
SCROLLBAR_ALWAYS
static BScrollPane.ScrollbarPolicy
SCROLLBAR_AS_NEEDED
static BScrollPane.ScrollbarPolicy
SCROLLBAR_NEVER

Constructor Summary

BScrollPane()
Create a new BScrollPane with no content or header Widgets.
BScrollPane(BScrollPane.ScrollbarPolicy horizontalPolicy, BScrollPane.ScrollbarPolicy verticalPolicy)
Create a new BScrollPane with no content or header Widgets.
BScrollPane(Widget contentWidget)
Create a new BScrollPane with the specified Widget as its content.
BScrollPane(Widget contentWidget, BScrollPane.ScrollbarPolicy horizontalPolicy, BScrollPane.ScrollbarPolicy verticalPolicy)
Create a new BScrollPane with the specified Widget as its content.

Method Summary

int
getChildCount()
Get the number of children in this container.
Iterator
getChildren()
Get an Iterator listing all child Widgets.
Widget
getColHeader()
Get the column header Widget.
Widget
getContent()
Get the content Widget.
boolean
getForceHeight()
Get whether the BScrollPane should force the height of the content and row header Widgets to exactly match the height of the visible area.
boolean
getForceWidth()
Get whether the BScrollPane should force the width of the content and column header Widgets to exactly match the width of the visible area.
BScrollBar
getHorizontalScrollBar()
Get the horizontal BScrollBar.
BScrollPane.ScrollbarPolicy
getHorizontalScrollbarPolicy()
Get the horizontal scrollbar policy.
Dimension
getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn.
Dimension
getPreferredSize()
Get the preferred size at which this Widget will look best.
Dimension
getPreferredViewSize()
Get the preferred size for the content's view area.
Widget
getRowHeader()
Get the row header Widget.
BScrollBar
getVerticalScrollBar()
Get the vertical BScrollBar.
BScrollPane.ScrollbarPolicy
getVerticalScrollbarPolicy()
Get the vertical scrollbar policy.
Dimension
getViewSize()
Get the current size of the content's view area.
void
layoutChildren()
Layout the child Widgets.
void
remove(Widget widget)
Remove a child Widget from this container.
void
removeAll()
Remove the content, row header, and column header Widgets from this container.
void
setBackground(Color background)
Set the background color of this Widget.
void
setColHeader(Widget widget)
Set the column header Widget.
void
setContent(Widget widget)
Set the content Widget.
void
setForceHeight(boolean force)
Set whether the BScrollPane should force the height of the content and row header Widgets to exactly match the height of the visible area.
void
setForceWidth(boolean force)
Set whether the BScrollPane should force the width of the content and column header Widgets to exactly match the width of the visible area.
void
setHorizontalScrollbarPolicy(BScrollPane.ScrollbarPolicy policy)
Set the horizontal scrollbar policy.
void
setPreferredViewSize(Dimension size)
Set the preferred size for the content's view area.
void
setRowHeader(Widget widget)
Set the row header Widget.
void
setVerticalScrollbarPolicy(BScrollPane.ScrollbarPolicy policy)
Set the vertical scrollbar policy.

Methods inherited from class buoy.widget.WidgetContainer

getChildCount, getChildren, isOpaque, layoutChildren, remove, removeAll, setOpaque

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible

Methods inherited from class buoy.event.EventSource

addEventLink, addEventLink, addEventLink, dispatchEvent, removeEventLink

Field Details

SCROLLBAR_ALWAYS

public static final BScrollPane.ScrollbarPolicy SCROLLBAR_ALWAYS

SCROLLBAR_AS_NEEDED

public static final BScrollPane.ScrollbarPolicy SCROLLBAR_AS_NEEDED

SCROLLBAR_NEVER

public static final BScrollPane.ScrollbarPolicy SCROLLBAR_NEVER

Constructor Details

BScrollPane

public BScrollPane()
Create a new BScrollPane with no content or header Widgets. The horizontal and vertical scrollbar policies default to SCROLLBAR_AS_NEEDED.

BScrollPane

public BScrollPane(BScrollPane.ScrollbarPolicy horizontalPolicy,
                   BScrollPane.ScrollbarPolicy verticalPolicy)
Create a new BScrollPane with no content or header Widgets.
Parameters:
horizontalPolicy - specifies when the horizontal scrollbar should be displayed. This should be equal to SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.
verticalPolicy - specifies when the vertical scrollbar should be displayed. This should be equal to SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

BScrollPane

public BScrollPane(Widget contentWidget)
Create a new BScrollPane with the specified Widget as its content. The horizontal and vertical scrollbar policies default to SCROLLBAR_AS_NEEDED.
Parameters:
contentWidget - the Widget to use as the content of the BScrollPane

BScrollPane

public BScrollPane(Widget contentWidget,
                   BScrollPane.ScrollbarPolicy horizontalPolicy,
                   BScrollPane.ScrollbarPolicy verticalPolicy)
Create a new BScrollPane with the specified Widget as its content.
Parameters:
contentWidget - the Widget to use as the content of the BScrollPane
horizontalPolicy - specifies when the horizontal scrollbar should be displayed. This should be equal to SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.
verticalPolicy - specifies when the vertical scrollbar should be displayed. This should be equal to SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

Method Details

getChildCount

public int getChildCount()
Get the number of children in this container.
Overrides:
getChildCount in interface WidgetContainer

getChildren

public Iterator getChildren()
Get an Iterator listing all child Widgets.
Overrides:
getChildren in interface WidgetContainer

getColHeader

public Widget getColHeader()
Get the column header Widget.

getContent

public Widget getContent()
Get the content Widget.

getForceHeight

public boolean getForceHeight()
Get whether the BScrollPane should force the height of the content and row header Widgets to exactly match the height of the visible area. By default, this is true if the vertical scrollbar policy was initialized to SCROLLBAR_NEVER, and false otherwise.

Note that even if this option is enabled, the BScrollPane will never make the content Widget smaller than its minimum size or larger than its maximum size.


getForceWidth

public boolean getForceWidth()
Get whether the BScrollPane should force the width of the content and column header Widgets to exactly match the width of the visible area. By default, this is true if the horizontal scrollbar policy was initialized to SCROLLBAR_NEVER, and false otherwise.

Note that even if this option is enabled, the BScrollPane will never make the content Widget smaller than its minimum size or larger than its maximum size.


getHorizontalScrollBar

public BScrollBar getHorizontalScrollBar()
Get the horizontal BScrollBar.

getHorizontalScrollbarPolicy

public BScrollPane.ScrollbarPolicy getHorizontalScrollbarPolicy()
Get the horizontal scrollbar policy. This will be either SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

getMinimumSize

public Dimension getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out its contents, it will attempt never to make this Widget smaller than its minimum size.
Overrides:
getMinimumSize in interface Widget

getPreferredSize

public Dimension getPreferredSize()
Get the preferred size at which this Widget will look best. When a WidgetContainer lays out its contents, it will attempt to make this Widget as close as possible to its preferred size.
Overrides:
getPreferredSize in interface Widget

getPreferredViewSize

public Dimension getPreferredViewSize()
Get the preferred size for the content's view area. This may be null, in which case the preferred view size is equal to the preferred size of the content Widget.

getRowHeader

public Widget getRowHeader()
Get the row header Widget.

getVerticalScrollBar

public BScrollBar getVerticalScrollBar()
Get the vertical BScrollBar.

getVerticalScrollbarPolicy

public BScrollPane.ScrollbarPolicy getVerticalScrollbarPolicy()
Get the vertical scrollbar policy. This will be either SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

getViewSize

public Dimension getViewSize()
Get the current size of the content's view area.

layoutChildren

public void layoutChildren()
Layout the child Widgets. This may be invoked whenever something has changed (the size of this WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be called in turn.
Overrides:
layoutChildren in interface WidgetContainer

remove

public void remove(Widget widget)
Remove a child Widget from this container. The scrollbars are built into the scroll pane and may never be removed, although they can be hidden by setting the appropriate scrollbar policy to SCROLLBAR_NEVER.
Overrides:
remove in interface WidgetContainer

removeAll

public void removeAll()
Remove the content, row header, and column header Widgets from this container. The scrollbars are built into the scroll pane and may never be removed, although they can be hidden by setting the appropriate scrollbar policy to SCROLLBAR_NEVER.
Overrides:
removeAll in interface WidgetContainer

setBackground

public void setBackground(Color background)
Set the background color of this Widget. If this is set to null, the Widget will use the background color of its parent WidgetContainer.
Overrides:
setBackground in interface Widget

setColHeader

public void setColHeader(Widget widget)
Set the column header Widget.

setContent

public void setContent(Widget widget)
Set the content Widget.

setForceHeight

public void setForceHeight(boolean force)
Set whether the BScrollPane should force the height of the content and row header Widgets to exactly match the height of the visible area. By default, this is true if the vertical scrollbar policy was initialized to SCROLLBAR_NEVER, and false otherwise.

Note that even if this option is enabled, the BScrollPane will never make the content Widget smaller than its minimum size or larger than its maximum size.


setForceWidth

public void setForceWidth(boolean force)
Set whether the BScrollPane should force the width of the content and column header Widgets to exactly match the width of the visible area. By default, this is true if the horizontal scrollbar policy was initialized to SCROLLBAR_NEVER, and false otherwise.

Note that even if this option is enabled, the BScrollPane will never make the content Widget smaller than its minimum size or larger than its maximum size.


setHorizontalScrollbarPolicy

public void setHorizontalScrollbarPolicy(BScrollPane.ScrollbarPolicy policy)
Set the horizontal scrollbar policy. This should be either SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

setPreferredViewSize

public void setPreferredViewSize(Dimension size)
Set the preferred size for the content's view area. This may be null, in which case the preferred view size is equal to the preferred size of the content Widget.

setRowHeader

public void setRowHeader(Widget widget)
Set the row header Widget.

setVerticalScrollbarPolicy

public void setVerticalScrollbarPolicy(BScrollPane.ScrollbarPolicy policy)
Set the vertical scrollbar policy. This should be either SCROLLBAR_ALWAYS, SCROLLBAR_AS_NEEDED, or SCROLLBAR_NEVER.

Written by Peter Eastman.