buoy.widget

Class BSpinner


public class BSpinner
extends Widget

A BSpinner is a Widget that allows the user to select a value from an ordered sequence. It allows the user to enter a value, and also provides a pair of arrows for stepping through the values in the sequence.

The list of allowed values is determined by a javax.swing.SpinnerModel. BSpinner provides constructors for handling the most common cases: a range of numbers, a date, or a fixed list of objects. For other cases, you can explicitly set the model by calling setModel(), or by using the constructor which takes a SpinnerModel.

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

Author:
Peter Eastman

Constructor Summary

BSpinner()
Create a new BSpinner which allows the user to select an arbitrary integer.
BSpinner(Date date)
Create a new BSpinner which allows the user to select a date.
BSpinner(SpinnerModel model)
Create a new BSpinner.
BSpinner(double value, double min, double max, double step)
Create a new BSpinner which allows the user to select floating point numbers in a fixed range.
BSpinner(int value, int min, int max, int step)
Create a new BSpinner which allows the user to select integers in a fixed range.
BSpinner(values[] )
Create a new BSpinner which allows the user to select from a fixed list of objects.

Method Summary

void
commitEdit()
If the user adjusts the spinner by typing a value (rather than clicking the arrows), the new value is not actually parsed and "committed" until they press return.
SpinnerModel
getModel()
Get the model for this spinner.
Object
getValue()
Get the current value of the spinner.
void
setModel(SpinnerModel model)
Set the model for this spinner.
void
setValue(Object value)
Set the current value of the spinner.

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

Constructor Details

BSpinner

public BSpinner()
Create a new BSpinner which allows the user to select an arbitrary integer. The initial value is 0.

BSpinner

public BSpinner(Date date)
Create a new BSpinner which allows the user to select a date.
Parameters:
date - the initial value

BSpinner

public BSpinner(SpinnerModel model)
Create a new BSpinner.
Parameters:
model - the model which specifies the values for the spinner.

BSpinner

public BSpinner(double value,
                double min,
                double max,
                double step)
Create a new BSpinner which allows the user to select floating point numbers in a fixed range.
Parameters:
value - the initial value
min - the minimum allowed value
max - the maximum allowed value
step - the amount by which the value changes when the user clicks the arrows

BSpinner

public BSpinner(int value,
                int min,
                int max,
                int step)
Create a new BSpinner which allows the user to select integers in a fixed range.
Parameters:
value - the initial value
min - the minimum allowed value
max - the maximum allowed value
step - the amount by which the value changes when the user clicks the arrows

BSpinner

public BSpinner(values[] )
Create a new BSpinner which allows the user to select from a fixed list of objects. The initial value is the first element in the list.
Parameters:

Method Details

commitEdit

public void commitEdit()
            throws ParseException
If the user adjusts the spinner by typing a value (rather than clicking the arrows), the new value is not actually parsed and "committed" until they press return. Call this method to immediately commit an edited value.

Note: calling commitEdit() will not generate a ValueChangedEvent.


getModel

public SpinnerModel getModel()
Get the model for this spinner.

getValue

public Object getValue()
Get the current value of the spinner.

setModel

public void setModel(SpinnerModel model)
Set the model for this spinner.

setValue

public void setValue(Object value)
Set the current value of the spinner.

Written by Peter Eastman.