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

Name Method
AutoArrowDisable setAutoArrowDisable
Alignment setAlignment
Background setBackground
Changed setChanged
Columns setColumns
CursorPosition setCursorPosition
DecimalPlaces setDecimalPlaces
DoubleBuffer setDoubleBuffer
Font setFont
Foreground setForeground
Editable setEditable
HighlightColor setHighlightColor
HighlightThickness setHighlightThickness
Increment setIncrement
Insets setInsets
Maximum setMaximum
MaximumLength setMaximumLength
Minimum setMinimum
Overstrike setOverstrike
Position setPosition
PreferredSize setPreferredSize
SelectedBackground setSelectedBackground
SelectedForeground setSelectedForeground
SelectionEnd setSelectionEnd
SelectionList setSelectionList
SelectionStart setSelectionStart
ShadowThickness setShadowThickness
ShowCursorPosition setShowCursorPosition
StringCase setStringCase
Text setText
UserData setUserData

Events

JCTextEvent JCTextCursorEvent
Class Listener Description
JCSpinBoxEvent addSpinBoxListener Posted when the user changes the value
addTextListener Posted when the value changes
addTextCursorListener Posted when the cursor is moved


Variable Index

 o auto_arrow_disable
 o decimals
 o decr_arrow
 o DECREMENT
 o incr
 o incr_arrow
 o INCREMENT
 o listeners
List of JCSpinBoxEvent listeners
 o max
 o min
 o NONE
 o position
 o shadow
The container's shadow thickness.
 o text
 o value

Constructor Index

 o JCSpinBox()
Creates an empty SpinBox.
 o JCSpinBox(Applet, String)
Creates a SpinBox which reads parameters from the applet's HTML file.
 o JCSpinBox(int)
Creates an empty SpinBox with the specified number of columns.

Method Index

 o actionPerformed(JCActionEvent)
If an arrow button was pressed, calls setTextAction.
If the user changed the text field's value, calls validate.
 o addFocusListener(FocusListener)
Add focus listener to the TextComponent Since the JCSpinBox itself never receives focus it is necessary to be able to set it
 o addKeyListener(KeyListener)
Add key listener to the TextComponent Since the JCSpinBox itself never receives focus it is necessary to be able to set it
 o addSpinBoxListener(JCSpinBoxListener)
Adds the specified JCSpinBoxEvent listener to receive value change events.
 o addTextCursorListener(JCTextCursorListener)
Adds the specified JCTextCursorEvent listener to receive cursor movement events.
 o addTextListener(JCTextListener)
Adds the specified listener to receive text events.
 o append(String)
Appends text to the end.
 o beep()
Emits a beep.
 o calcValue(int)
Gets the value to be displayed
 o enableArrowButtons()
Disables the arrow buttons if the end of the range is reached.
 o getAlignment()
Gets the field's alignment.
 o getAutoArrowDisable()
Gets the AutoArrowDisable value.
 o getChanged()
Returns true if the user has changed the value since the last programmatic setting.
 o getColumns()
Returns the number of columns.
 o getCursorPosition()
Gets the position of the cursor.
 o getDecimalPlaces()
Gets the DecimalPlaces value.
 o getDecimalPointChar()
Gets the decimal point char.
 o getDecrementArrow()
Gets the decrement (down) button.
 o getEditable()
Returns the boolean indicating whether this component is editable or not.
 o getHighlightColor()
Gets the color of the highlight rectangle.
 o getHighlightThickness()
Gets the thickness of the highlight rectangle.
 o getIncrement()
Gets the Increment value.
 o getIncrementArrow()
Gets the increment (up) button.
 o getIntValue()
Gets the current value as an int.
 o getLastPosition()
Gets the position of the last character in the text.
 o getMaximum()
Gets the Maximum value.
 o getMaximumLength()
Gets the MaximumLength value.
 o getMinimum()
Gets the Minimum value.
 o getMinimumSize(int)
Returns the minimum size needed for the specified number of columns.
 o getOverstrike()
Gets the Overstrike value.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getPosition()
Gets the Position value.
 o getSelectedBackground()
Gets the SelectedBackground value.
 o getSelectedForeground()
Gets the SelectedForeground value.
 o getSelectedText()
Returns the selected text contained in this component.
 o getSelectionEnd()
Returns the selected text's end position.
 o getSelectionList()
Gets the current SelectionList.
 o getSelectionStart()
Returns the selected text's start position.
 o getShadowThickness()
Gets the shadow's thickness.

HTML param name/value: "ShadowThickness"/int

 o getShowCursorPosition()
Gets the ShowCursorPosition value.
 o getStringCase()
Gets the StringCase value.
 o getText()
Gets the value of the text.
 o getTextField()
Gets the component to be used as the data entry field.
 o getValue()
Gets the current value as a string.
 o initTextValue()
Sets the text field's initial value.
 o insert(String, int)
Inserts text at the specified position.
 o isEditable()
Returns the boolean indicating whether this component is editable or not.
 o layout()
Positions the text field and arrow buttons.
 o paintInterior(Graphics)
Draws the shadows.
 o pointToPosition(int, int)
Maps a physical position to the corresponding character position.
 o postSpinBoxEvent(int, Object)
Posts a JCSpinBoxEvent
 o preferredHeight()
Returns the text field's preferred height.
 o preferredWidth()
Returns the sum of the text field's and arrow button's preferred widths.
 o removeFocusListener(FocusListener)
Remove focus listener to the TextComponent
 o removeKeyListener(KeyListener)
Remove focus listener to the TextComponent
 o removeSpinBoxListener(JCSpinBoxListener)
Removes the specified listener so it no longer receives JCSpinBoxEvents.
 o removeTextCursorListener(JCTextCursorListener)
Removes the specified listener so it no longer receives JCTextCursorEvents.
 o removeTextListener(JCTextListener)
Removes the specified text listener so it no longer receives text events.
 o replaceRange(String, int, int)
Replaces text between two positions with the specified text.
 o select(int, int)
Selects the text found between the specified start and end locations.
 o selectAll()
Selects all the text in the component.
 o setAlignment(int)
Sets the position of the text:
BWTEnum.LEFT (default), CENTER, or RIGHT.
 o setAutoArrowDisable(boolean)
If true (default), the increment or decrement arrow button is disabled when the end of the range is reached.
 o setChanged(boolean)
Resets the Changed flag.
 o setColumns(int)
Sets the number of columns.
 o setCursorPosition(int)
Sets the position of the cursor.
 o setDecimalPlaces(int)
Sets the number of decimal points used when displaying the value (default: 0).

HTML param name/value: "DecimalPlaces"/int

 o setEditable(boolean)
Determines whether this component is editable.
 o setHighlightColor(Color)
Sets the color of the rectangle drawn when the component has focus (default: black).

HTML param name/value: "HighlightColor"/Color

 o setHighlightThickness(int)
Sets the thickness of the rectangle drawn when the component has focus (default: 2).

HTML param name/value: "HighlightThickness"/int

 o setIncrement(int)
Sets the amount by which to increment or decrement the value (default: 1).

HTML param name/value: "Increment"/int

 o setIntValue(int)
Sets the current value as an int.
 o setLayout(LayoutManager)
Sets the layout manager for this container.
 o setMaximum(int)
Sets the highest possible value (default: BWTEnum.MAXINT).

HTML param name/value: "Maximum"/int

 o setMaximumLength(int)
Sets the maximum number of characters which may be entered by the user (default: BWTEnum.MAXINT).
 o setMinimum(int)
Sets the lowest possible value (default: 0).

HTML param name/value: "Minimum"/int

 o setOverstrike(boolean)
If false (default), characters typed by the user are inserted into the current text.
 o setPosition(int)
Sets the position of the currently displayed item (default: 0) (the position in the range of possible values).
 o setSelectedBackground(Color)
Sets the background color of selected text (default: blue).

HTML param name/value: "SelectedBackground"/color

 o setSelectedForeground(Color)
Sets the foreground color of selected text (default: background color).

HTML param name/value: "SelectedForeground"/color

 o setSelectionEnd(int)
Sets the selected text's end position.
 o setSelectionList(int[])
Sets a list of values used for multi-click.
 o setSelectionStart(int)
Sets the selected text's start position.
 o setShadowThickness(int)
Sets the shadow's thickness (default: 2)
 o setShowCursorPosition(boolean)
If set to true (default), the cursor position will be indicated with a vertical I-beam.
 o 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
 o setText(String)
Sets the text field's value to the specified string.

HTML param name/value: "Text"/string

 o setTextAction(int)
Sets the text field's value after an arrow key is hit.
 o setTextValue(Object)
Sets the text field's value.
 o showPosition(int)
Scrolls the text if necessary to ensure that the position is visible.
 o validate(Object)
Validates the text field's value after the user has changed it.
 o validateKey(char)
Validates a key typed into the text field.

Variables

 o text
 protected SpinField text
 o decr_arrow
 protected JCArrowButton decr_arrow
 o incr_arrow
 protected JCArrowButton incr_arrow
 o position
 protected int position
 o min
 protected int min
 o max
 protected int max
 o incr
 protected int incr
 o decimals
 protected int decimals
 o value
 protected Object value
 o auto_arrow_disable
 protected boolean auto_arrow_disable
 o shadow
 protected int shadow
The container's shadow thickness.

 o NONE
 protected static final int NONE
 o INCREMENT
 protected static final int INCREMENT
 o DECREMENT
 protected static final int DECREMENT
 o listeners
 protected JCVector listeners
List of JCSpinBoxEvent listeners

Constructors

 o JCSpinBox
 public JCSpinBox()
Creates an empty SpinBox. No parameters are read from an HTML file.

 o JCSpinBox
 public JCSpinBox(int cols)
Creates an empty SpinBox with the specified number of columns. No parameters are read from an HTML file.

 o 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

Methods

 o 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
 o getTextField
 public JCTextField getTextField()
Gets the component to be used as the data entry field.

 o getDecrementArrow
 public JCArrowButton getDecrementArrow()
Gets the decrement (down) button.

 o getIncrementArrow
 public JCArrowButton getIncrementArrow()
Gets the increment (up) button.

 o getAutoArrowDisable
 public boolean getAutoArrowDisable()
Gets the AutoArrowDisable value.

See Also:
setAutoArrowDisable
 o 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

 o getDecimalPlaces
 public int getDecimalPlaces()
Gets the DecimalPlaces value.

See Also:
setDecimalPlaces
 o 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

 o getIncrement
 public int getIncrement()
Gets the Increment value.

See Also:
setIncrement
 o 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

 o getMinimum
 public int getMinimum()
Gets the Minimum value.

See Also:
setMinimum
 o setMinimum
 public void setMinimum(int v)
Sets the lowest possible value (default: 0).

HTML param name/value: "Minimum"/int

 o getMaximum
 public int getMaximum()
Gets the Maximum value.

See Also:
setMaximum
 o setMaximum
 public void setMaximum(int v)
Sets the highest possible value (default: BWTEnum.MAXINT).

HTML param name/value: "Maximum"/int

 o getPosition
 public int getPosition()
Gets the Position value.

See Also:
setPosition
 o 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

 o getIntValue
 public int getIntValue()
Gets the current value as an int.

 o setIntValue
 public void setIntValue(int v)
Sets the current value as an int.

 o getValue
 public String getValue()
Gets the current value as a string.

 o setText
 public synchronized void setText(String s)
Sets the text field's value to the specified string.

HTML param name/value: "Text"/string

 o getText
 public synchronized String getText()
Gets the value of the text.

See Also:
setText
 o addSpinBoxListener
 public void addSpinBoxListener(JCSpinBoxListener l)
Adds the specified JCSpinBoxEvent listener to receive value change events.

See Also:
JCSpinBoxEvent
 o removeSpinBoxListener
 public void removeSpinBoxListener(JCSpinBoxListener l)
Removes the specified listener so it no longer receives JCSpinBoxEvents.

See Also:
addSpinBoxListener
 o preferredWidth
 protected int preferredWidth()
Returns the sum of the text field's and arrow button's preferred widths.

Overrides:
preferredWidth in class JCContainer
 o preferredHeight
 protected int preferredHeight()
Returns the text field's preferred height.

Overrides:
preferredHeight in class JCContainer
 o layout
 public synchronized void layout()
Positions the text field and arrow buttons.

Overrides:
layout in class Container
 o paintInterior
 public void paintInterior(Graphics gc)
Draws the shadows.

Overrides:
paintInterior in class JCContainer
 o 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
 o removeKeyListener
 public void removeKeyListener(KeyListener l)
Remove focus listener to the TextComponent

Overrides:
removeKeyListener in class Component
See Also:
addKeyListener
 o 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
 o removeFocusListener
 public void removeFocusListener(FocusListener l)
Remove focus listener to the TextComponent

Overrides:
removeFocusListener in class Component
See Also:
addFocusListener
 o getSelectedText
 public String getSelectedText()
Returns the selected text contained in this component.

See Also:
setText
 o isEditable
 public boolean isEditable()
Returns the boolean indicating whether this component is editable or not.

See Also:
setEditable
 o getEditable
 public boolean getEditable()
Returns the boolean indicating whether this component is editable or not.

See Also:
setEditable
 o setEditable
 public void setEditable(boolean t)
Determines whether this component is editable.

See Also:
isEditable
 o getSelectionStart
 public int getSelectionStart()
Returns the selected text's start position.

 o getSelectionEnd
 public int getSelectionEnd()
Returns the selected text's end position.

 o setSelectionStart
 public void setSelectionStart(int pos)
Sets the selected text's start position.

 o setSelectionEnd
 public void setSelectionEnd(int pos)
Sets the selected text's end position.

 o select
 public void select(int start,
                    int end)
Selects the text found between the specified start and end locations.

 o selectAll
 public void selectAll()
Selects all the text in the component.

 o insert
 public void insert(String str,
                    int pos)
Inserts text at the specified position.

See Also:
setText, replaceRange
 o append
 public void append(String str)
Appends text to the end.

See Also:
insert
 o replaceRange
 public void replaceRange(String str,
                          int start,
                          int end)
Replaces text between two positions with the specified text.

 o getColumns
 public int getColumns()
Returns the number of columns.

 o setColumns
 public void setColumns(int v)
Sets the number of columns.

 o getAlignment
 public int getAlignment()
Gets the field's alignment.

See Also:
setAlignment
 o setAlignment
 public void setAlignment(int v)
Sets the position of the text:
BWTEnum.LEFT (default), CENTER, or RIGHT.

 o getMaximumLength
 public int getMaximumLength()
Gets the MaximumLength value.

See Also:
setMaximumLength
 o 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.

 o getStringCase
 public int getStringCase()
Gets the StringCase value.

See Also:
setStringCase
 o 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

 o beep
 public void beep()
Emits a beep.

 o getChanged
 public boolean getChanged()
Returns true if the user has changed the value since the last programmatic setting.

 o setChanged
 public void setChanged(boolean v)
Resets the Changed flag.

See Also:
setChanged
 o getMinimumSize
 public Dimension getMinimumSize(int columns)
Returns the minimum size needed for the specified number of columns.

 o getSelectionList
 public int[] getSelectionList()
Gets the current SelectionList.

See Also:
setSelectionList
 o 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 }

 o getSelectedBackground
 public Color getSelectedBackground()
Gets the SelectedBackground value.

See Also:
setSelectedBackground
 o setSelectedBackground
 public void setSelectedBackground(Color v)
Sets the background color of selected text (default: blue).

HTML param name/value: "SelectedBackground"/color

See Also:
toColor
 o getSelectedForeground
 public Color getSelectedForeground()
Gets the SelectedForeground value.

See Also:
setSelectedForeground
 o 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
 o pointToPosition
 public int pointToPosition(int x,
                            int y)
Maps a physical position to the corresponding character position.

 o 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.
 o getCursorPosition
 public int getCursorPosition()
Gets the position of the cursor.

See Also:
setCursorPosition
 o setCursorPosition
 public void setCursorPosition(int pos)
Sets the position of the cursor.

 o setOverstrike
 public void setOverstrike(boolean v)
If false (default), characters typed by the user are inserted into the current text.

 o getOverstrike
 public boolean getOverstrike()
Gets the Overstrike value.

See Also:
setOverstrike
 o 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.

 o getShowCursorPosition
 public boolean getShowCursorPosition()
Gets the ShowCursorPosition value.

See Also:
setShowCursorPosition
 o setShowCursorPosition
 public void setShowCursorPosition(boolean v)
If set to true (default), the cursor position will be indicated with a vertical I-beam.

 o addTextListener
 public void addTextListener(JCTextListener l)
Adds the specified listener to receive text events.

See Also:
JCTextEvent
 o removeTextListener
 public void removeTextListener(JCTextListener l)
Removes the specified text listener so it no longer receives text events.

 o addTextCursorListener
 public void addTextCursorListener(JCTextCursorListener l)
Adds the specified JCTextCursorEvent listener to receive cursor movement events.

See Also:
JCTextCursorEvent
 o removeTextCursorListener
 public void removeTextCursorListener(JCTextCursorListener l)
Removes the specified listener so it no longer receives JCTextCursorEvents.

See Also:
addTextCursorListener
 o getShadowThickness
 public int getShadowThickness()
Gets the shadow's thickness.

HTML param name/value: "ShadowThickness"/int

See Also:
setShadowThickness
 o setShadowThickness
 public void setShadowThickness(int v)
Sets the shadow's thickness (default: 2)

 o getHighlightThickness
 public int getHighlightThickness()
Gets the thickness of the highlight rectangle.

See Also:
setHighlightThickness
 o 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
 o getHighlightColor
 public Color getHighlightColor()
Gets the color of the highlight rectangle.

See Also:
setHighlightColor
 o 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
 o 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
 o getDecimalPointChar
 protected char getDecimalPointChar()
Gets the decimal point char.

 o calcValue
 protected Object calcValue(int dir)
Gets the value to be displayed

Parameters:
dir - INCREMENT, DECREMENT or NONE
 o initTextValue
 protected void initTextValue()
Sets the text field's initial value.

 o setTextValue
 protected void setTextValue(Object value)
Sets the text field's value.

 o setTextAction
 public void setTextAction(int dir)
Sets the text field's value after an arrow key is hit.

Parameters:
dir - INCREMENT, DECREMENT or NONE
 o enableArrowButtons
 protected void enableArrowButtons()
Disables the arrow buttons if the end of the range is reached.

See Also:
setAutoArrowDisable
 o validateKey
 protected boolean validateKey(char key)
Validates a key typed into the text field.

Returns:
false if the key is invalid
 o 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
 o 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
 o 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