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 JCTextInterface, 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
-
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.
-
addFocusListener(FocusListener)
- Add focus listener to the TextComponent
Since the JCSpinBox itself never receives focus it is necessary
to be able to set it
-
addKeyListener(KeyListener)
- Add key listener to the TextComponent
Since the JCSpinBox itself never receives focus it is necessary
to be able to set it
-
addSpinBoxListener(JCSpinBoxListener)
- Adds the specified JCSpinBoxEvent listener to receive value change events.
-
addTextCursorListener(JCTextCursorListener)
- Adds the specified JCTextCursorEvent listener to receive cursor movement events.
-
addTextListener(JCTextListener)
- Adds the specified listener to receive text events.
-
append(String)
- Appends text to the end.
-
beep()
- Emits a beep.
-
calcValue(int)
- Gets the value to be displayed
-
enableArrowButtons()
- Disables the arrow buttons if the end of the range is reached.
-
getAlignment()
- Gets the field's alignment.
-
getAutoArrowDisable()
- Gets the AutoArrowDisable value.
-
getChanged()
- Returns true if the user has changed the value since the last
programmatic setting.
-
getColumns()
- Returns the number of columns.
-
getCursorPosition()
- Gets the position of the cursor.
-
getDecimalPlaces()
- Gets the DecimalPlaces value.
-
getDecimalPointChar()
- Gets the decimal point char.
-
getDecrementArrow()
- Gets the decrement (down) button.
-
getEditable()
- Returns the boolean indicating whether this component is editable or not.
-
getHighlightColor()
- Gets the color of the highlight rectangle.
-
getHighlightThickness()
- Gets the thickness of the highlight rectangle.
-
getIncrement()
- Gets the Increment value.
-
getIncrementArrow()
- Gets the increment (up) button.
-
getIntValue()
- Gets the current value as an int.
-
getLastPosition()
- Gets the position of the last character in the text.
-
getMaximum()
- Gets the Maximum value.
-
getMaximumLength()
- Gets the MaximumLength value.
-
getMinimum()
- Gets the Minimum value.
-
getMinimumSize(int)
- Returns the minimum size needed for the specified number of columns.
-
getOverstrike()
- Gets the Overstrike value.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getPosition()
- Gets the Position value.
-
getSelectedBackground()
- Gets the SelectedBackground value.
-
getSelectedForeground()
- Gets the SelectedForeground value.
-
getSelectedText()
- Returns the selected text contained in this component.
-
getSelectionEnd()
- Returns the selected text's end position.
-
getSelectionList()
- Gets the current SelectionList.
-
getSelectionStart()
- Returns the selected text's start position.
-
getShadowThickness()
- Gets the shadow's thickness.
HTML param name/value: "ShadowThickness"/int
-
getShowCursorPosition()
- Gets the ShowCursorPosition value.
-
getStringCase()
- Gets the StringCase 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.
-
insert(String, int)
- Inserts text at the specified position.
-
isEditable()
- Returns the boolean indicating whether this component is editable or not.
-
layout()
- Positions the text field and arrow buttons.
-
paintInterior(Graphics)
- Draws the shadows.
-
pointToPosition(int, int)
- Maps a physical position to the corresponding character position.
-
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.
-
removeFocusListener(FocusListener)
- Remove focus listener to the TextComponent
-
removeKeyListener(KeyListener)
- Remove focus listener to the TextComponent
-
removeSpinBoxListener(JCSpinBoxListener)
- Removes the specified listener so it no longer receives JCSpinBoxEvents.
-
removeTextCursorListener(JCTextCursorListener)
- Removes the specified listener so it no longer receives JCTextCursorEvents.
-
removeTextListener(JCTextListener)
- Removes the specified text listener so it no longer receives text events.
-
replaceRange(String, int, int)
- Replaces text between two positions with the specified text.
-
select(int, int)
- Selects the text found between the specified start and end locations.
-
selectAll()
- Selects all the text in the component.
-
setAlignment(int)
- Sets the position of the text:
BWTEnum.LEFT (default), CENTER, or RIGHT.
-
setAutoArrowDisable(boolean)
- If true (default), the increment or decrement arrow button is disabled
when the end of the range is reached.
-
setChanged(boolean)
- Resets the Changed flag.
-
setColumns(int)
- Sets the number of columns.
-
setCursorPosition(int)
- Sets the position of the cursor.
-
setDecimalPlaces(int)
- Sets the number of decimal points used when displaying the value
(default: 0).
HTML param name/value: "DecimalPlaces"/int
-
setEditable(boolean)
- Determines whether this component is editable.
-
setHighlightColor(Color)
- Sets the color of the rectangle drawn when the component has focus
(default: black).
HTML param name/value: "HighlightColor"/Color
-
setHighlightThickness(int)
- Sets the thickness of the rectangle drawn when the component has focus (default: 2).
HTML param name/value: "HighlightThickness"/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
-
setMaximumLength(int)
- Sets the maximum number of characters which may be entered by the user
(default: BWTEnum.MAXINT).
-
setMinimum(int)
- Sets the lowest possible value (default: 0).
HTML param name/value: "Minimum"/int
-
setOverstrike(boolean)
- If false (default), characters typed by the user are inserted into
the current text.
-
setPosition(int)
- Sets the position of the currently displayed item (default: 0)
(the position in the range of possible values).
-
setSelectedBackground(Color)
- Sets the background color of selected text (default: blue).
HTML param name/value: "SelectedBackground"/color
-
setSelectedForeground(Color)
- Sets the foreground color of selected text (default: background color).
HTML param name/value: "SelectedForeground"/color
-
setSelectionEnd(int)
- Sets the selected text's end position.
-
setSelectionList(int[])
- Sets a list of values used for multi-click.
-
setSelectionStart(int)
- Sets the selected text's start position.
-
setShadowThickness(int)
- Sets the shadow's thickness (default: 2)
-
setShowCursorPosition(boolean)
-
If set to true (default), the cursor position will be indicated with
a vertical I-beam.
-
setStringCase(int)
- Sets the case of text entered by the user or set programmatically:
BWTEnum.CASE_AS_IS No conversion (default)
BWTEnum.CASE_LOWER Convert to lower case
BWTEnum.CASE_UPPER Convert to upper case
-
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.
-
showPosition(int)
- Scrolls the text if necessary to ensure that the position is visible.
-
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
addKeyListener
public void addKeyListener(KeyListener l)
- Add key listener to the TextComponent
Since the JCSpinBox itself never receives focus it is necessary
to be able to set it
- Overrides:
- addKeyListener in class Component
- See Also:
- removeKeyListener
removeKeyListener
public void removeKeyListener(KeyListener l)
- Remove focus listener to the TextComponent
- Overrides:
- removeKeyListener in class Component
- See Also:
- addKeyListener
addFocusListener
public void addFocusListener(FocusListener l)
- Add focus listener to the TextComponent
Since the JCSpinBox itself never receives focus it is necessary
to be able to set it
- Overrides:
- addFocusListener in class Component
- See Also:
- removeFocusListener
removeFocusListener
public void removeFocusListener(FocusListener l)
- Remove focus listener to the TextComponent
- Overrides:
- removeFocusListener in class Component
- See Also:
- addFocusListener
getSelectedText
public String getSelectedText()
- Returns the selected text contained in this component.
- See Also:
- setText
isEditable
public boolean isEditable()
- Returns the boolean indicating whether this component is editable or not.
- See Also:
- setEditable
getEditable
public boolean getEditable()
- Returns the boolean indicating whether this component is editable or not.
- See Also:
- setEditable
setEditable
public void setEditable(boolean t)
- Determines whether this component is editable.
- See Also:
- isEditable
getSelectionStart
public int getSelectionStart()
- Returns the selected text's start position.
getSelectionEnd
public int getSelectionEnd()
- Returns the selected text's end position.
setSelectionStart
public void setSelectionStart(int pos)
- Sets the selected text's start position.
setSelectionEnd
public void setSelectionEnd(int pos)
- Sets the selected text's end position.
select
public void select(int start,
int end)
- Selects the text found between the specified start and end locations.
selectAll
public void selectAll()
- Selects all the text in the component.
insert
public void insert(String str,
int pos)
- Inserts text at the specified position.
- See Also:
- setText, replaceRange
append
public void append(String str)
- Appends text to the end.
- See Also:
- insert
replaceRange
public void replaceRange(String str,
int start,
int end)
- Replaces text between two positions with the specified text.
getColumns
public int getColumns()
- Returns the number of columns.
setColumns
public void setColumns(int v)
- Sets the number of columns.
getAlignment
public int getAlignment()
- Gets the field's alignment.
- See Also:
- setAlignment
setAlignment
public void setAlignment(int v)
- Sets the position of the text:
BWTEnum.LEFT (default), CENTER, or RIGHT.
getMaximumLength
public int getMaximumLength()
- Gets the MaximumLength value.
- See Also:
- setMaximumLength
setMaximumLength
public void setMaximumLength(int v)
- Sets the maximum number of characters which may be entered by the user
(default: BWTEnum.MAXINT). If the user attempts to enter more characters,
the values will be ignored and the bell will be sounded.
This value is ignored for values set programmatically.
getStringCase
public int getStringCase()
- Gets the StringCase value.
- See Also:
- setStringCase
setStringCase
public void setStringCase(int v)
- Sets the case of text entered by the user or set programmatically:
BWTEnum.CASE_AS_IS No conversion (default)
BWTEnum.CASE_LOWER Convert to lower case
BWTEnum.CASE_UPPER Convert to upper case
beep
public void beep()
- Emits a beep.
getChanged
public boolean getChanged()
- Returns true if the user has changed the value since the last
programmatic setting.
setChanged
public void setChanged(boolean v)
- Resets the Changed flag.
- See Also:
- setChanged
getMinimumSize
public Dimension getMinimumSize(int columns)
- Returns the minimum size needed for the specified number of columns.
getSelectionList
public int[] getSelectionList()
- Gets the current SelectionList.
- See Also:
- setSelectionList
setSelectionList
public void setSelectionList(int list[])
- Sets a list of values used for multi-click. As the mouse is clicked in
rapid succession, each click selects the next type in the list.
Valid BWTEnum values (in order of the default list):
SELECT_POSITION Selects the current pointer position
SELECT_WORD Selects the current word
SELECT_LINE Selects the current line
SELECT_PARAGRAPH Selects the current paragraph
SELECT_ALL Selects all the text
Default list: { BWTEnum.SELECT_POSITION, SELECT_WORD, SELECT_LINE, SELECT_ALL }
getSelectedBackground
public Color getSelectedBackground()
- Gets the SelectedBackground value.
- See Also:
- setSelectedBackground
setSelectedBackground
public void setSelectedBackground(Color v)
- Sets the background color of selected text (default: blue).
HTML param name/value: "SelectedBackground"/color
- See Also:
- toColor
getSelectedForeground
public Color getSelectedForeground()
- Gets the SelectedForeground value.
- See Also:
- setSelectedForeground
setSelectedForeground
public void setSelectedForeground(Color v)
- Sets the foreground color of selected text (default: background color).
HTML param name/value: "SelectedForeground"/color
- See Also:
- toColor
pointToPosition
public int pointToPosition(int x,
int y)
- Maps a physical position to the corresponding character position.
showPosition
public void showPosition(int pos)
- Scrolls the text if necessary to ensure that the position is visible.
- Parameters:
- pos - the number of characters from the beginning of the text buffer.
getCursorPosition
public int getCursorPosition()
- Gets the position of the cursor.
- See Also:
- setCursorPosition
setCursorPosition
public void setCursorPosition(int pos)
- Sets the position of the cursor.
setOverstrike
public void setOverstrike(boolean v)
- If false (default), characters typed by the user are inserted into
the current text.
getOverstrike
public boolean getOverstrike()
- Gets the Overstrike value.
- See Also:
- setOverstrike
getLastPosition
public int getLastPosition()
- Gets the position of the last character in the text.
This represents the position that text appended to the component would be
placed after.
getShowCursorPosition
public boolean getShowCursorPosition()
- Gets the ShowCursorPosition value.
- See Also:
- setShowCursorPosition
setShowCursorPosition
public void setShowCursorPosition(boolean v)
- If set to true (default), the cursor position will be indicated with
a vertical I-beam.
addTextListener
public void addTextListener(JCTextListener l)
- Adds the specified listener to receive text events.
- See Also:
- JCTextEvent
removeTextListener
public void removeTextListener(JCTextListener l)
- Removes the specified text listener so it no longer receives text events.
addTextCursorListener
public void addTextCursorListener(JCTextCursorListener l)
- Adds the specified JCTextCursorEvent listener to receive cursor movement events.
- See Also:
- JCTextCursorEvent
removeTextCursorListener
public void removeTextCursorListener(JCTextCursorListener l)
- Removes the specified listener so it no longer receives JCTextCursorEvents.
- See Also:
- addTextCursorListener
getShadowThickness
public int getShadowThickness()
- Gets the shadow's thickness.
HTML param name/value: "ShadowThickness"/int
- See Also:
- setShadowThickness
setShadowThickness
public void setShadowThickness(int v)
- Sets the shadow's thickness (default: 2)
getHighlightThickness
public int getHighlightThickness()
- Gets the thickness of the highlight rectangle.
- See Also:
- setHighlightThickness
setHighlightThickness
public void setHighlightThickness(int v)
- Sets the thickness of the rectangle drawn when the component has focus (default: 2).
HTML param name/value: "HighlightThickness"/int
- See Also:
- toInt
getHighlightColor
public Color getHighlightColor()
- Gets the color of the highlight rectangle.
- See Also:
- setHighlightColor
setHighlightColor
public void setHighlightColor(Color v)
- Sets the color of the rectangle drawn when the component has focus
(default: black).
HTML param name/value: "HighlightColor"/Color
- See Also:
- toColor
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