    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 KeyListener, 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
Background | setBackground
DecimalPlaces | setDecimalPlaces
DoubleBuffer | setDoubleBuffer
Font | setFont
Foreground | setForeground
Increment | setIncrement
Insets | setInsets
Maximum | setMaximum
Minimum | setMinimum
Position | setPosition
PreferredSize | setPreferredSize
UserData | setUserData

Events

Class | Listener | Description
--- | --- | ---
JCSpinBoxEvent | addSpinBoxListener | Posted when the user changes the value

##

DECREMENT
INCREMENT
listeners
  List of JCSpinBoxEvent listeners
NONE
shadow
  The container's shadow thickness.

##

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.
keyPressed(KeyEvent)
keyReleased(KeyEvent)
keyTyped(KeyEvent)
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.

##

shadow

      protected int shadow

  The container's shadow thickness.

NONE

      protected final static int NONE

INCREMENT

      protected final static int INCREMENT

DECREMENT

      protected final static 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:
    getParam

##

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

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

keyPressed

      public void keyPressed(KeyEvent ev)

keyReleased

      public void keyReleased(KeyEvent ev)

keyTyped

      public void keyTyped(KeyEvent ev)

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