|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectComponent
Container
JComponent
JTextComponent
JTextField
JValueField
JIntegerField
public class JIntegerField
A text field control to work with integer values. It can be constrained to positive values if
desired. It also provides an API for listening to value changes that is simpler than messing
about with Swing KeyListener
and DocumentListener
.
Example of use:
int initialValue = ...
boolean allowNegatives = false;
JIntegerField control = new JIntegerField(initialValue, allowNegatives);
control.addValueChangedListener( new ValueChangedListener() {
public void onValueChanged( ValueChangedEvent ev ) {
System.out.println("The new value is " + ev.getValue());
}
});
modules/unsupported/swing (gt-swing.jar)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class JTextField |
---|
JTextField.AccessibleJTextField |
Nested classes/interfaces inherited from class JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class JTextField |
---|
notifyAction |
Fields inherited from class JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JIntegerField()
Creates a new text field that allows negative values and has an initial value of 0. |
|
JIntegerField(boolean allowsNegative)
Creates a new text field with an initial value of 0. |
|
JIntegerField(int value)
Creates a new text field that allows negative values and the given initial value. |
|
JIntegerField(int value,
boolean allowNegative)
Creates a new text field with the given initial value. |
Method Summary | |
---|---|
int |
getValue()
Get the current value of this control. |
void |
setValue(int value)
Set the integer value of this control. |
void |
setValue(int value,
boolean publishEvent)
Set the integer value of this control, optionally skipping notification of the change to listeners. |
Methods inherited from class JValueField |
---|
addValueChangedListener, fireValueChangedEvent, removeValueChangedListener |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JIntegerField()
public JIntegerField(boolean allowsNegative)
allowNegative
- true if this field should allow negative values to
be entered; false if only positive values are allowedpublic JIntegerField(int value)
value
- the initial value to displaypublic JIntegerField(int value, boolean allowNegative)
value
- the initial value to displayallowNegative
- true if this field should allow negative values to
be entered; false if only positive values are allowedMethod Detail |
---|
public int getValue()
public void setValue(int value)
ValueChangedEvent
will be
published to all ValueChangedListeners
.
value
- the value to set
IllegalArgumentException
- if value
is negative but the field
only allows positive valuespublic void setValue(int value, boolean publishEvent)
This version is useful when two or more controls are synchronized (ie. changes to the value of one control results in changes to the values of other controls). In such a setting, firing change events can result in an endless cycle or a mutex violation.
value
- the value to setpublishEvent
- true to notify listeners of this change; false to skip
notification
IllegalArgumentException
- if value
is negative but the field
only allows positive values
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |