buoy.widget

Class BSplitPane


public class BSplitPane
extends WidgetContainer

BSplitPane is a WidgetContainer whose space is divided between two child Widgets. A drag bar is placed between them, which the user can move to change how much space is given to each child.

In addition to the event types generated by all Widgets, BSplitPanes generate the following event types:

Author:
Peter Eastman

Nested Class Summary

static class
BSplitPane.Orientation
This inner class represents an orientation (horizontal or vertical) for the split.

Field Summary

static BSplitPane.Orientation
HORIZONTAL
static BSplitPane.Orientation
VERTICAL

Constructor Summary

BSplitPane()
Create a new BSplitPane which is split horizontally to place its children side by side.
BSplitPane(BSplitPane.Orientation orient)
Create a new BSplitPane.
BSplitPane(BSplitPane.Orientation orient, Widget child1, Widget child2)
Create a new BSplitPane.

Method Summary

void
add(Widget widget, int index)
Add a Widget to this container.
Widget
getChild(int index)
Get one of the child Widgets.
int
getChildCount()
Get the number of children in this container.
Collection
getChildren()
Get a Collection containing all child Widgets of this container.
JSplitPane
getComponent()
int
getDividerLocation()
Get the location of the divider (in pixels).
Dimension
getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn.
BSplitPane.Orientation
getOrientation()
Get which way the container is split, HORIZONTAL or VERTICAL.
Dimension
getPreferredSize()
Get the preferred size at which this Widget will look best.
double
getResizeWeight()
Get how extra space is divided between the two child widgets.
boolean
isContinuousLayout()
Get whether the container should continuously resize its children as the divider bar is dragged, or only when the mouse is released.
boolean
isOneTouchExpandable()
Get whether the divider provides a control to collapse or expand the split with a single click.
void
layoutChildren()
Layout the child Widgets.
void
remove(Widget widget)
Remove a child Widget from this container.
void
remove(int index)
Remove a child Widget from this container.
void
removeAll()
Remove all child Widgets from this container.
void
resetToPreferredSizes()
Reposition the divider based on the minimum and preferred sizes of the child widgets, and the current resize weight.
void
setContinuousLayout(boolean continuous)
Set whether the container should continuously resize its children as the divider bar is dragged, or only when the mouse is released.
void
setDividerLocation(double location)
Set the location of the divider as a fraction of the total size of the container.
void
setDividerLocation(int location)
Set the location of the divider (in pixels).
void
setOneTouchExpandable(boolean expandable)
Set whether the divider provides a control to collapse or expand the split with a single click.
void
setOrientation(BSplitPane.Orientation orient)
Set which way the container is split, HORIZONTAL or VERTICAL.
void
setResizeWeight(double weight)
Set how extra space is divided between the two child widgets.

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

HORIZONTAL

public static final BSplitPane.Orientation HORIZONTAL

VERTICAL

public static final BSplitPane.Orientation VERTICAL

Constructor Details

BSplitPane

public BSplitPane()
Create a new BSplitPane which is split horizontally to place its children side by side.

BSplitPane

public BSplitPane(BSplitPane.Orientation orient)
Create a new BSplitPane.
Parameters:
orient - the split orientation (HORIZONTAL or VERTICAL)

BSplitPane

public BSplitPane(BSplitPane.Orientation orient,
                  Widget child1,
                  Widget child2)
Create a new BSplitPane.
Parameters:
orient - the split orientation (HORIZONTAL or VERTICAL)
child1 - the first (top or left) child Widget
child2 - the second (bottom or right) child Widget

Method Details

add

public void add(Widget widget,
                int index)
Add a Widget to this container. If there is already a Widget in the specified position, it is removed before the new one is added.
Parameters:
widget - the Widget to add
index - the position at which to add it (0 or 1)

getChild

public Widget getChild(int index)
Get one of the child Widgets.
Parameters:
index - the index of the Widget to get (0 or 1)

getChildCount

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

getChildren

public Collection getChildren()
Get a Collection containing all child Widgets of this container.
Overrides:
getChildren in interface WidgetContainer

getComponent

public JSplitPane getComponent()
Overrides:
getComponent in interface Widget

getDividerLocation

public int getDividerLocation()
Get the location of the divider (in pixels).

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

getOrientation

public BSplitPane.Orientation getOrientation()
Get which way the container is split, HORIZONTAL or VERTICAL.

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

getResizeWeight

public double getResizeWeight()
Get how extra space is divided between the two child widgets. A weight of 0 gives all extra space to the second child, while a weight of 1 gives all extra space to the first child. Values between 0 and 1 divide the extra space proportionally between the two.

isContinuousLayout

public boolean isContinuousLayout()
Get whether the container should continuously resize its children as the divider bar is dragged, or only when the mouse is released.

isOneTouchExpandable

public boolean isOneTouchExpandable()
Get whether the divider provides a control to collapse or expand the split with a single click.

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.
Overrides:
remove in interface WidgetContainer
Parameters:
widget - the Widget to remove

remove

public void remove(int index)
Remove a child Widget from this container.
Parameters:
index - the index of the Widget to remove (0 or 1)

removeAll

public void removeAll()
Remove all child Widgets from this container.
Overrides:
removeAll in interface WidgetContainer

resetToPreferredSizes

public void resetToPreferredSizes()
Reposition the divider based on the minimum and preferred sizes of the child widgets, and the current resize weight.

setContinuousLayout

public void setContinuousLayout(boolean continuous)
Set whether the container should continuously resize its children as the divider bar is dragged, or only when the mouse is released.

setDividerLocation

public void setDividerLocation(double location)
Set the location of the divider as a fraction of the total size of the container. 0.0 is all the way to the top/left, and 1.0 is all the way to the bottom/right.

setDividerLocation

public void setDividerLocation(int location)
Set the location of the divider (in pixels).

setOneTouchExpandable

public void setOneTouchExpandable(boolean expandable)
Set whether the divider provides a control to collapse or expand the split with a single click.

setOrientation

public void setOrientation(BSplitPane.Orientation orient)
Set which way the container is split, HORIZONTAL or VERTICAL.

setResizeWeight

public void setResizeWeight(double weight)
Set how extra space is divided between the two child widgets. A weight of 0 gives all extra space to the second child, while a weight of 1 gives all extra space to the first child. Values between 0 and 1 divide the extra space proportionally between the two.

Written by Peter Eastman.