buoy.widget

Class 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

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, 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 BSlider.Orientation HORIZONTAL

VERTICAL

public static final BSlider.Orientation VERTICAL

Constructor Details

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 Details

getMajorTickSpacing

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

getMaximum

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

getMinimum

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

getMinorTickSpacing

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

getOrientation

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

getShowLabels

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

getShowTicks

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

getSnapToTicks

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

getValue

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

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.


setMaximum

public void setMaximum(int value)
Set the maximum 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.

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.


setOrientation

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

setShowLabels

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

setShowTicks

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

setSnapToTicks

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

setValue

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

Written by Peter Eastman.