buoy.widget
Class BSplitPane

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.WidgetContainer
              extended by buoy.widget.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.
 java.util.Collection<Widget> getChildren()
          Get a Collection containing all child Widgets of this container.
 javax.swing.JSplitPane getComponent()
          Get the java.awt.Component corresponding to this Widget.
 int getDividerLocation()
          Get the location of the divider (in pixels).
 java.awt.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.
 java.awt.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(int index)
          Remove a child Widget from this container.
 void remove(Widget widget)
          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
isOpaque, setOpaque
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getName, getParent, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final BSplitPane.Orientation HORIZONTAL

VERTICAL

public static final BSplitPane.Orientation VERTICAL
Constructor Detail

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 Detail

getComponent

public javax.swing.JSplitPane getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getDividerLocation

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


setDividerLocation

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


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.


resetToPreferredSizes

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


getOrientation

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


setOrientation

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


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.


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.


isOneTouchExpandable

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


setOneTouchExpandable

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


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.


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.


getChildCount

public int getChildCount()
Get the number of children in this container.

Specified by:
getChildCount in class WidgetContainer

getChildren

public java.util.Collection<Widget> getChildren()
Get a Collection containing all child Widgets of this container.

Specified by:
getChildren in class WidgetContainer

getChild

public Widget getChild(int index)
Get one of the child Widgets.

Parameters:
index - the index of the Widget to get (0 or 1)

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.

Specified by:
layoutChildren in class WidgetContainer

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)

remove

public void remove(Widget widget)
Remove a child Widget from this container.

Specified by:
remove in class 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.

Specified by:
removeAll in class WidgetContainer

getMinimumSize

public java.awt.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 class Widget

getPreferredSize

public java.awt.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 class Widget


Written by Peter Eastman.