public class BSpinner extends Widget
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:
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
addEventLink, addEventLink, removeEventLink
public BSpinner()
public BSpinner(javax.swing.SpinnerModel model)
model
- the model which specifies the values for the spinner.public BSpinner(int value, int min, int max, int step)
value
- the initial valuemin
- the minimum allowed valuemax
- the maximum allowed valuestep
- the amount by which the value changes when the user clicks the arrowspublic BSpinner(double value, double min, double max, double step)
value
- the initial valuemin
- the minimum allowed valuemax
- the maximum allowed valuestep
- the amount by which the value changes when the user clicks the arrowspublic BSpinner(java.util.Date date)
date
- the initial valuepublic BSpinner(java.lang.Object[] values)
values
- the list of allowed valuespublic javax.swing.JSpinner getComponent()
Widget
getComponent
in class Widget
public java.lang.Object getValue()
public void setValue(java.lang.Object value)
public void commitEdit() throws java.text.ParseException
Note: calling commitEdit() will not generate a ValueChangedEvent.
java.text.ParseException
public javax.swing.SpinnerModel getModel()
public void setModel(javax.swing.SpinnerModel model)
Written by Peter Eastman.