buoy.widget
Class BSpinner

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.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(java.util.Date date)
          Create a new BSpinner which allows the user to select a date.
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(java.lang.Object[] values)
          Create a new BSpinner which allows the user to select from a fixed list of objects.
BSpinner(javax.swing.SpinnerModel model)
          Create a new BSpinner.
 
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.
 javax.swing.JSpinner getComponent()
          Get the java.awt.Component corresponding to this Widget.
 javax.swing.SpinnerModel getModel()
          Get the model for this spinner.
 java.lang.Object getValue()
          Get the current value of the spinner.
 void setModel(javax.swing.SpinnerModel model)
          Set the model for this spinner.
 void setValue(java.lang.Object value)
          Set the current value of the spinner.
 
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
 

Constructor Detail

BSpinner

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


BSpinner

public BSpinner(javax.swing.SpinnerModel model)
Create a new BSpinner.

Parameters:
model - the model which specifies the values for the spinner.

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(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(java.util.Date date)
Create a new BSpinner which allows the user to select a date.

Parameters:
date - the initial value

BSpinner

public BSpinner(java.lang.Object[] 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:
values - the list of allowed values
Method Detail

getComponent

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

Overrides:
getComponent in class Widget

getValue

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


setValue

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


commitEdit

public void commitEdit()
                throws java.text.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.

Throws:
java.text.ParseException

getModel

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


setModel

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



Written by Peter Eastman.