com.toedter.components
Class JSpinField
JPanel
com.toedter.components.JSpinField
- ActionListener, CaretListener, ChangeListener
public class JSpinField
extends JPanel
implements ChangeListener, CaretListener, ActionListener
JSpinField2 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.
JSpinField() - Default JSpinField constructor.
|
JSpinField(int min, int max) - JSpinField constructor with given minimum and maximum vaues..
|
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.
|
int | getMaximum() - Returns the maximum value.
|
int | getMinimum() - Returns the minimum value.
|
String | getName() - Returns "JSpinField".
|
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) - DOCUMENT ME!
|
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.
JSpinField
public JSpinField(int min,
int max)
JSpinField constructor with given minimum and maximum vaues..
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.
e
- Description of the Parameter
getMaximum
public int getMaximum()
Returns the maximum value.
getMinimum
public int getMinimum()
Returns the minimum value.
getName
public String getName()
Returns "JSpinField".
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)
DOCUMENT ME!
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 - 2004 Kai Toedter.