buoy.widget
Class BSlider

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.BSlider

public class BSlider
extends Widget

A BSlider is a Widget that allows the user to select a single value by dragging a "thumb" along a bar. It can optionally show tick marks, labels, or both along the bar.

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

Author:
Peter Eastman

Nested Class Summary
static class BSlider.Orientation
          This inner class represents an orientation for the slider.
 
Field Summary
static BSlider.Orientation HORIZONTAL
           
static BSlider.Orientation VERTICAL
           
 
Constructor Summary
BSlider()
          Create a new vertical BSlider.
BSlider(int value, int minimum, int maximum, BSlider.Orientation orientation)
          Create a new BSlider.
 
Method Summary
 javax.swing.JSlider getComponent()
          Get the java.awt.Component corresponding to this Widget.
 int getMajorTickSpacing()
          Get the spacing between major tick marks on the slider.
 int getMaximum()
          Get the maximum value of the range represented by this BSlider.
 int getMinimum()
          Get the minimum value of the range represented by this BSlider.
 int getMinorTickSpacing()
          Get the spacing between minor tick marks on the slider.
 BSlider.Orientation getOrientation()
          Get the orientation (HORIZONTAL or VERTICAL) of this BSlider.
 boolean getShowLabels()
          Get whether labels are shown on the slider at the major tick positions.
 boolean getShowTicks()
          Get whether tick marks are shown on the slider.
 boolean getSnapToTicks()
          Get whether the thumb of the slider should always snap to the nearest tick position.
 int getValue()
          Get the current value of this BSlider.
 void setMajorTickSpacing(int spacing)
          Set the spacing between major tick marks on the slider.
 void setMaximum(int value)
          Set the maximum value of the range represented by this BSlider.
 void setMinimum(int value)
          Set the minimum value of the range represented by this BSlider.
 void setMinorTickSpacing(int spacing)
          Set the spacing between minor tick marks on the slider.
 void setOrientation(BSlider.Orientation orientation)
          Set the orientation (HORIZONTAL or VERTICAL) of this BSlider.
 void setShowLabels(boolean show)
          Set whether labels are shown on the slider at the major tick positions.
 void setShowTicks(boolean show)
          Set whether tick marks are shown on the slider.
 void setSnapToTicks(boolean snap)
          Set whether the thumb of the slider should always snap to the nearest tick position.
 void setValue(int value)
          Set the current value of this BSlider.
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, 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, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final BSlider.Orientation HORIZONTAL

VERTICAL

public static final BSlider.Orientation VERTICAL
Constructor Detail

BSlider

public BSlider()
Create a new vertical BSlider.


BSlider

public BSlider(int value,
               int minimum,
               int maximum,
               BSlider.Orientation orientation)
Create a new BSlider.

Parameters:
value - the BSlider's initial value
minimum - the minimum value for the range represented by the BSlider
maximum - the maximum value for the range represented by the BSlider
orientation - defines how the BSlider should be drawn and positioned. This should be HORIZONTAL or VERTICAL.
Method Detail

getComponent

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

Overrides:
getComponent in class Widget

getMinimum

public int getMinimum()
Get the minimum value of the range represented by this BSlider.


setMinimum

public void setMinimum(int value)
Set the minimum value of the range represented by this BSlider.


getMaximum

public int getMaximum()
Get the maximum value of the range represented by this BSlider.


setMaximum

public void setMaximum(int value)
Set the maximum value of the range represented by this BSlider.


getValue

public int getValue()
Get the current value of this BSlider.


setValue

public void setValue(int value)
Set the current value of this BSlider.


getOrientation

public BSlider.Orientation getOrientation()
Get the orientation (HORIZONTAL or VERTICAL) of this BSlider.


setOrientation

public void setOrientation(BSlider.Orientation orientation)
Set the orientation (HORIZONTAL or VERTICAL) of this BSlider.


getMajorTickSpacing

public int getMajorTickSpacing()
Get the spacing between major tick marks on the slider.


setMajorTickSpacing

public void setMajorTickSpacing(int spacing)
Set the spacing between major tick marks on the slider.

The major tick spacing can never be smaller than the minor tick spacing. If the current minor tick spacing is greater than the value passed to this method, then the minor tick spacing will also be set to the same value.


getMinorTickSpacing

public int getMinorTickSpacing()
Get the spacing between minor tick marks on the slider.


setMinorTickSpacing

public void setMinorTickSpacing(int spacing)
Set the spacing between minor tick marks on the slider.

The minor tick spacing can never be larger than the major tick spacing. If the current major tick spacing is less than the value passed to this method, then the major tick spacing will also be set to the same value.


getShowTicks

public boolean getShowTicks()
Get whether tick marks are shown on the slider.


setShowTicks

public void setShowTicks(boolean show)
Set whether tick marks are shown on the slider.


getShowLabels

public boolean getShowLabels()
Get whether labels are shown on the slider at the major tick positions.


setShowLabels

public void setShowLabels(boolean show)
Set whether labels are shown on the slider at the major tick positions.


getSnapToTicks

public boolean getSnapToTicks()
Get whether the thumb of the slider should always snap to the nearest tick position.


setSnapToTicks

public void setSnapToTicks(boolean snap)
Set whether the thumb of the slider should always snap to the nearest tick position.



Written by Peter Eastman.