com.toedter.components
Class JSpinField
JPanel
com.toedter.components.JSpinField
- ActionListener, CaretListener, ChangeListener, FocusListener
public class JSpinField
extends JPanel
implements ChangeListener, CaretListener, ActionListener, FocusListener
JSpinField is a numeric field with 2 spin buttons to increase or decrease the
value. It has the same interface as the "old" JSpinField but uses a JSpinner
internally (since J2SE SDK 1.4) rather than a scrollbar for emulating the
spin buttons.
$LastChangedRevision: 85 $, $LastChangedDate: 2006-04-28 13:50:52 +0200 (Fr, 28 Apr 2006) $
JSpinField() - Default JSpinField constructor.
|
JSpinField(int min, int max) - JSpinField constructor with given minimum and maximum vaues and initial
value 0.
|
void | actionPerformed(ActionEvent e) - After any user input, the value of the textfield is proofed.
|
void | adjustWidthToMaximumValue()
|
void | caretUpdate(CaretEvent e) - After any user input, the value of the textfield is proofed.
|
void | focusGained(FocusEvent e)
|
void | focusLost(FocusEvent e) - The value of the text field is checked against a valid (green) value.
|
int | getMaximum() - Returns the maximum value.
|
int | getMinimum() - Returns the minimum value.
|
Component | getSpinner() - Returns the year chooser's spinner (which allow the focus to be set to
it).
|
int | getValue() - Returns the value.
|
static void | main(String[] s) - Creates a JFrame with a JSpinField inside and can be used for testing.
|
void | setEnabled(boolean enabled) - Enable or disable the JSpinField.
|
void | setFont(Font font) - Sets the font property.
|
void | setForeground(Color fg) - Sets the foreground
|
void | setHorizontalAlignment(int alignment) - Sets the horizontal alignment of the displayed value.
|
void | setMaximum(int newMaximum) - Sets the maximum value and adjusts the preferred width.
|
void | setMinimum(int newMinimum) - Sets the minimum value.
|
void | setValue(int newValue) - Sets the value.
|
protected void | setValue(int newValue, boolean updateTextField, boolean firePropertyChange) - Sets the value attribute of the JSpinField object.
|
void | stateChanged(ChangeEvent e) - Is invoked when the spinner model changes
|
darkGreen
protected Color darkGreen
spinner
protected JSpinner spinner
textField
protected JTextField textField
the text (number) field
JSpinField
public JSpinField()
Default JSpinField constructor. The valid value range is between
Integer.MIN_VALUE and Integer.MAX_VALUE. The initial value is 0.
JSpinField
public JSpinField(int min,
int max)
JSpinField constructor with given minimum and maximum vaues and initial
value 0.
actionPerformed
public void actionPerformed(ActionEvent e)
After any user input, the value of the textfield is proofed. Depending on
being an integer, the value is colored green or red. If the textfield is
green, the enter key is accepted and the new value is set.
e
- Description of the Parameter
adjustWidthToMaximumValue
public void adjustWidthToMaximumValue()
caretUpdate
public void caretUpdate(CaretEvent e)
After any user input, the value of the textfield is proofed. Depending on
being an integer, the value is colored green or red.
focusGained
public void focusGained(FocusEvent e)
focusLost
public void focusLost(FocusEvent e)
The value of the text field is checked against a valid (green) value. If
valid, the value is set and a property change is fired.
getMaximum
public int getMaximum()
Returns the maximum value.
getMinimum
public int getMinimum()
Returns the minimum value.
getSpinner
public Component getSpinner()
Returns the year chooser's spinner (which allow the focus to be set to
it).
- Component the spinner or null, if the month chooser has no
spinner
getValue
public int getValue()
Returns the value.
main
public static void main(String[] s)
Creates a JFrame with a JSpinField inside and can be used for testing.
s
- The command line arguments
setEnabled
public void setEnabled(boolean enabled)
Enable or disable the JSpinField.
enabled
- The new enabled value
setFont
public void setFont(Font font)
Sets the font property.
setForeground
public void setForeground(Color fg)
Sets the foreground
setHorizontalAlignment
public void setHorizontalAlignment(int alignment)
Sets the horizontal alignment of the displayed value.
alignment
- the horizontal alignment
setMaximum
public void setMaximum(int newMaximum)
Sets the maximum value and adjusts the preferred width.
newMaximum
- the new maximum value
setMinimum
public void setMinimum(int newMinimum)
Sets the minimum value.
newMinimum
- the new minimum value
setValue
public void setValue(int newValue)
Sets the value. This is a bound property.
setValue
protected void setValue(int newValue,
boolean updateTextField,
boolean firePropertyChange)
Sets the value attribute of the JSpinField object.
newValue
- The new valueupdateTextField
- true if text field should be updated
stateChanged
public void stateChanged(ChangeEvent e)
Is invoked when the spinner model changes
Copyright B) 1999 - 2009 Kai Toedter.