All Packages Class Hierarchy This Package Previous Next Index
Class jclass.bwt.JCSpinBox
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----jclass.bwt.JCContainer
|
+----jclass.bwt.JCSpinBox
- public class JCSpinBox
- extends JCContainer
- implements JCActionListener
JCSpinBox provides the capabilities of an JCTextField and 2 JCArrowButtons.
The user can choose from a range of numeric values.
By default, the text field is editable. If the user attempts to enter an
invalid value, it is disallowed.
Properties
Events
Class | Listener | Description |
JCSpinBoxEvent | addSpinBoxListener | Posted when the user changes the value |
-
auto_arrow_disable
-
-
decimals
-
-
decr_arrow
-
-
DECREMENT
-
-
incr
-
-
incr_arrow
-
-
INCREMENT
-
-
listeners
- List of JCSpinBoxEvent listeners
-
max
-
-
min
-
-
NONE
-
-
position
-
-
shadow
- The container's shadow thickness.
-
text
-
-
value
-
-
JCSpinBox()
- Creates an empty SpinBox.
-
JCSpinBox(Applet, String)
- Creates a SpinBox which reads parameters from the applet's HTML file.
-
JCSpinBox(int)
- Creates an empty SpinBox with the specified number of columns.
-
actionPerformed(JCActionEvent)
-
If an arrow button was pressed, calls setTextAction.
If the user changed the text field's value, calls validate.
-
addSpinBoxListener(JCSpinBoxListener)
- Adds the specified JCSpinBoxEvent listener to receive value change events.
-
calcValue(int)
- Gets the value to be displayed
-
enableArrowButtons()
- Disables the arrow buttons if the end of the range is reached.
-
getAutoArrowDisable()
- Gets the AutoArrowDisable value.
-
getDecimalPlaces()
- Gets the DecimalPlaces value.
-
getDecimalPointChar()
- Gets the decimal point char.
-
getDecrementArrow()
- Gets the decrement (down) button.
-
getIncrement()
- Gets the Increment value.
-
getIncrementArrow()
- Gets the increment (up) button.
-
getIntValue()
- Gets the current value as an int.
-
getMaximum()
- Gets the Maximum value.
-
getMinimum()
- Gets the Minimum value.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getPosition()
- Gets the Position value.
-
getText()
- Gets the value of the text.
-
getTextField()
- Gets the component to be used as the data entry field.
-
getValue()
- Gets the current value as a string.
-
initTextValue()
- Sets the text field's initial value.
-
layout()
- Positions the text field and arrow buttons.
-
paintInterior(Graphics)
- Draws the shadows.
-
postSpinBoxEvent(int, Object)
- Posts a JCSpinBoxEvent
-
preferredHeight()
- Returns the text field's preferred height.
-
preferredWidth()
- Returns the sum of the text field's and arrow button's preferred widths.
-
removeSpinBoxListener(JCSpinBoxListener)
- Removes the specified listener so it no longer receives JCSpinBoxEvents.
-
setAutoArrowDisable(boolean)
- If true (default), the increment or decrement arrow button is disabled
when the end of the range is reached.
-
setDecimalPlaces(int)
- Sets the number of decimal points used when displaying the value
(default: 0).
HTML param name/value: "DecimalPlaces"/int
-
setIncrement(int)
- Sets the amount by which to increment or decrement the value (default: 1).
HTML param name/value: "Increment"/int
-
setIntValue(int)
- Sets the current value as an int.
-
setLayout(LayoutManager)
-
Sets the layout manager for this container.
-
setMaximum(int)
- Sets the highest possible value (default: BWTEnum.MAXINT).
HTML param name/value: "Maximum"/int
-
setMinimum(int)
- Sets the lowest possible value (default: 0).
HTML param name/value: "Minimum"/int
-
setPosition(int)
- Sets the position of the currently displayed item (default: 0)
(the position in the range of possible values).
-
setText(String)
- Sets the text field's value to the specified string.
HTML param name/value: "Text"/string
-
setTextAction(int)
- Sets the text field's value after an arrow key is hit.
-
setTextValue(Object)
- Sets the text field's value.
-
validate(Object)
- Validates the text field's value after the user has changed it.
-
validateKey(char)
- Validates a key typed into the text field.
text
protected SpinField text
decr_arrow
protected JCArrowButton decr_arrow
incr_arrow
protected JCArrowButton incr_arrow
position
protected int position
min
protected int min
max
protected int max
incr
protected int incr
decimals
protected int decimals
value
protected Object value
auto_arrow_disable
protected boolean auto_arrow_disable
shadow
protected int shadow
- The container's shadow thickness.
NONE
protected static final int NONE
INCREMENT
protected static final int INCREMENT
DECREMENT
protected static final int DECREMENT
listeners
protected JCVector listeners
- List of JCSpinBoxEvent listeners
JCSpinBox
public JCSpinBox()
- Creates an empty SpinBox. No parameters are read from an HTML file.
JCSpinBox
public JCSpinBox(int cols)
- Creates an empty SpinBox with the specified number of columns.
No parameters are read from an HTML file.
JCSpinBox
public JCSpinBox(Applet applet,
String name)
- Creates a SpinBox which reads parameters from the applet's HTML file.
- Parameters:
- applet - the applet whose PARAM tags are to be read
- name - if this is not null, only parameters preceded by this name are read
- See Also:
- getParameter
getParameters
protected void getParameters()
- Reads the parameter values from the HTML page using the component's applet.
The values will override those previously set.
- Overrides:
- getParameters in class JCContainer
getTextField
public JCTextField getTextField()
- Gets the component to be used as the data entry field.
getDecrementArrow
public JCArrowButton getDecrementArrow()
- Gets the decrement (down) button.
getIncrementArrow
public JCArrowButton getIncrementArrow()
- Gets the increment (up) button.
getAutoArrowDisable
public boolean getAutoArrowDisable()
- Gets the AutoArrowDisable value.
- See Also:
- setAutoArrowDisable
setAutoArrowDisable
public void setAutoArrowDisable(boolean v)
- If true (default), the increment or decrement arrow button is disabled
when the end of the range is reached. If set to false, the buttons are
always enabled.
HTML param name/value: "AutoArrowDisable"/boolean
getDecimalPlaces
public int getDecimalPlaces()
- Gets the DecimalPlaces value.
- See Also:
- setDecimalPlaces
setDecimalPlaces
public void setDecimalPlaces(int v)
- Sets the number of decimal points used when displaying the value
(default: 0).
HTML param name/value: "DecimalPlaces"/int
getIncrement
public int getIncrement()
- Gets the Increment value.
- See Also:
- setIncrement
setIncrement
public void setIncrement(int v)
- Sets the amount by which to increment or decrement the value (default: 1).
HTML param name/value: "Increment"/int
getMinimum
public int getMinimum()
- Gets the Minimum value.
- See Also:
- setMinimum
setMinimum
public void setMinimum(int v)
- Sets the lowest possible value (default: 0).
HTML param name/value: "Minimum"/int
getMaximum
public int getMaximum()
- Gets the Maximum value.
- See Also:
- setMaximum
setMaximum
public void setMaximum(int v)
- Sets the highest possible value (default: BWTEnum.MAXINT).
HTML param name/value: "Maximum"/int
getPosition
public int getPosition()
- Gets the Position value.
- See Also:
- setPosition
setPosition
public void setPosition(int v)
- Sets the position of the currently displayed item (default: 0)
(the position in the range of possible values).
HTML param name/value: "Position"/int
getIntValue
public int getIntValue()
- Gets the current value as an int.
setIntValue
public void setIntValue(int v)
- Sets the current value as an int.
getValue
public String getValue()
- Gets the current value as a string.
setText
public synchronized void setText(String s)
- Sets the text field's value to the specified string.
HTML param name/value: "Text"/string
getText
public synchronized String getText()
- Gets the value of the text.
- See Also:
- setText
addSpinBoxListener
public void addSpinBoxListener(JCSpinBoxListener l)
- Adds the specified JCSpinBoxEvent listener to receive value change events.
- See Also:
- JCSpinBoxEvent
removeSpinBoxListener
public void removeSpinBoxListener(JCSpinBoxListener l)
- Removes the specified listener so it no longer receives JCSpinBoxEvents.
- See Also:
- addSpinBoxListener
preferredWidth
protected int preferredWidth()
- Returns the sum of the text field's and arrow button's preferred widths.
- Overrides:
- preferredWidth in class JCContainer
preferredHeight
protected int preferredHeight()
- Returns the text field's preferred height.
- Overrides:
- preferredHeight in class JCContainer
layout
public synchronized void layout()
- Positions the text field and arrow buttons.
- Overrides:
- layout in class Container
paintInterior
public void paintInterior(Graphics gc)
- Draws the shadows.
- Overrides:
- paintInterior in class JCContainer
postSpinBoxEvent
protected JCSpinBoxEvent postSpinBoxEvent(int stage,
Object value)
- Posts a JCSpinBoxEvent
- Returns:
- the posted event, or null if there are no listeners
- See Also:
- addSpinBoxListener, JCSpinBoxEvent
getDecimalPointChar
protected char getDecimalPointChar()
- Gets the decimal point char.
calcValue
protected Object calcValue(int dir)
- Gets the value to be displayed
- Parameters:
- dir - INCREMENT, DECREMENT or NONE
initTextValue
protected void initTextValue()
- Sets the text field's initial value.
setTextValue
protected void setTextValue(Object value)
- Sets the text field's value.
setTextAction
public void setTextAction(int dir)
- Sets the text field's value after an arrow key is hit.
- Parameters:
- dir - INCREMENT, DECREMENT or NONE
enableArrowButtons
protected void enableArrowButtons()
- Disables the arrow buttons if the end of the range is reached.
- See Also:
- setAutoArrowDisable
validateKey
protected boolean validateKey(char key)
- Validates a key typed into the text field.
- Returns:
- false if the key is invalid
validate
protected boolean validate(Object value)
- Validates the text field's value after the user has changed it.
If the value is valid, the position is determined.
- Returns:
- false if the value is invalid
- See Also:
- setPosition
actionPerformed
public void actionPerformed(JCActionEvent ev)
- If an arrow button was pressed, calls setTextAction.
If the user changed the text field's value, calls validate.
- See Also:
- setTextAction, validate
setLayout
public final void setLayout(LayoutManager mgr)
- Sets the layout manager for this container. This method is
overridden to prevent the layout mgr from being set.
- Overrides:
- setLayout in class Container
All Packages Class Hierarchy This Package Previous Next Index