Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## echopointng
Class Calculator

    java.lang.Object
      nextapp.echo2.app.Component
          echopointng.ComponentEx
              echopointng.AbleComponent
                  echopointng.Calculator

All Implemented Interfaces:
  AccessKeyable, Attributeable, Borderable, Delegateable, Heightable, Insetable, MouseCursorable, Sizeable, ToolTipable, Widthable, java.io.Serializable, RenderIdSupport

    public class Calculator

extends AbleComponent

`Calculator` is a component that acts like a hand held calculator.

Its acts a bit like a TextField in that it has a backing `Document` and it can raise action events when you press the Transfer button, if its present (which by default is not present).

The Transfer button can be used to raise an event so that other components can know about the contents of the Calculator.

Take care when setting text into the Calculator, it will call isValidNumber() to ensure that the calculator can take the input. if it cant (eg not a decimal number, then it will throw an IllegalArgumentException.

See Also:
  Serialized Form

Field Summary
`static java.lang.String` | `ACTION_LISTENERS_CHANGED_PROPERTY`
`static java.lang.String` | `DEFAULT_NUMBER_MASK`
`static Style` | `DEFAULT_STYLE`
`static java.lang.String` | `DOCUMENT_CHANGED_PROPERTY`
`static java.lang.String` | `INPUT_TRANSFER`
`static java.lang.String` | `PROPERTY_ACTION_COMMAND`
`static java.lang.String` | `PROPERTY_BUTTON_BACKGROUND`
`static java.lang.String` | `PROPERTY_BUTTON_HEIGHT`
`static java.lang.String` | `PROPERTY_BUTTON_NUMBER_FOREGROUND`
`static java.lang.String` | `PROPERTY_BUTTON_OPERATOR_FOREGROUND`
`static java.lang.String` | `PROPERTY_BUTTON_WIDTH`
`static java.lang.String` | `PROPERTY_DISPLAY_BACKGROUND`
`static java.lang.String` | `PROPERTY_DISPLAY_FONT`
`static java.lang.String` | `PROPERTY_DISPLAY_FOREGROUND`
`static java.lang.String` | `PROPERTY_MEMORY`
`static java.lang.String` | `PROPERTY_TRANSFER`
`static java.lang.String` | `TEXT_CHANGED_PROPERTY`

Fields inherited from class echopointng.ComponentEx
`PROPERTY_HIDDEN`

Fields inherited from class nextapp.echo2.app.Component
`CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY`

Fields inherited from interface echopointng.able.AccessKeyable
`PROPERTY_ACCESS_KEY`

Fields inherited from interface echopointng.able.Borderable
`PROPERTY_BORDER`

Fields inherited from interface echopointng.able.MouseCursorable
`CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, PROPERTY_MOUSE_CURSOR, PROPERTY_MOUSE_CURSOR_URI`

Fields inherited from interface echopointng.able.Insetable
`DEFAULT_INSETS, DEFAULT_OUTSETS, PROPERTY_INSETS, PROPERTY_OUTSETS`

Fields inherited from interface echopointng.able.Widthable
`PROPERTY_WIDTH`

Fields inherited from interface echopointng.able.Heightable
`PROPERTY_HEIGHT`

Fields inherited from interface echopointng.able.ToolTipable
`PROPERTY_TOOL_TIP_TEXT`

Constructor Summary
`Calculator()` Constructs a `Calculator`
`Calculator(Document document)` Constructs a `Calculator` with the specified backing Document

Method Summary
`void` | `addActionListener(ActionListener l)` Adds an `ActionListener` to the `Calculator`.
`java.lang.String` | `getActionCommand()` Returns the action command which will be provided in `ActionEvent` s fired by this `Calculator`.
`Color` | `getButtonBackground()`
`Extent` | `getButtonHeight()`
`Color` | `getButtonNumberForeground()`
`Color` | `getButtonOperatorForegound()`
`Extent` | `getButtonWidth()`
`Color` | `getDisplayBackground()`
`Font` | `getDisplayFont()`
`Color` | `getDisplayForeground()`
`Document` | `getDocument()` Returns the model associated with this `TextComponent`.
`java.lang.String` | `getMemory()`
`java.lang.String` | `getText()` Returns the text contained in the `Document` model of this text component.
`java.lang.String` | `getTransfer()`
`boolean` | `hasActionListeners()` Determines the any `ActionListener` s are registered.
`boolean` | `isValidNumber(java.lang.String numberText)` This method is called to determine wether the text parameter is a valid number to be placed inside the calculator or its memory.
`void` | `processInput(java.lang.String inputName, java.lang.Object inputValue)` Processes client input specific to the `Component` received from the `UpdateManager`.
`void` | `removeActionListener(ActionListener l)` Removes an `ActionListener` from the `Calculator`.
`void` | `setActionCommand(java.lang.String newValue)` Sets the action command which will be provided in `ActionEvent` s fired by this `Calculator`.
`void` | `setButtonBackground(Color newValue)` Sets the background color of the calculator's buttons
`void` | `setButtonHeight(Extent newValue)` Sets the height of the calculator's buttons
`void` | `setButtonNumberForeground(Color newValue)` Sets the foreground color of the calculator's buttons that are numbers
`void` | `setButtonOperatorForeground(Color newValue)` Sets the foreground color of the calculator's buttons that are operators
`void` | `setButtonWidth(Extent newValue)` Sets the width of the calculator's buttons
`void` | `setDisplayBackground(Color newValue)` Sets the background color of the calculator's number display
`void` | `setDisplayFont(Font newValue)` Sets the font of the calculator's number display
`void` | `setDisplayForeground(Color newValue)` Sets the foreground color of the calculator's number display
`void` | `setDocument(Document newValue)` Sets the model associated with this `TextComponent`.
`void` | `setMemory(java.lang.String newValue)` Sets the string value into the calculators memory
`void` | `setText(java.lang.String newValue)` Sets the text of the document model of this calculaor.
`void` | `setTransfer(java.lang.String newValue)` Sets the string value for the Transfer button.

Methods inherited from class echopointng.AbleComponent
`getAccessKey, getBorder, getHeight, getInsets, getMouseCursor, getMouseCursorURI, getOutsets, getToolTipText, getWidth, setAccessKey, setBorder, setHeight, setInsets, setMouseCursor, setMouseCursorURI, setOutsets, setToolTipText, setWidth`

Methods inherited from class echopointng.ComponentEx
`getAttribute, getAttributeNames, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, getRenderProperty, isHidden, setAttribute, setHidden, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty`

Methods inherited from class nextapp.echo2.app.Component
`add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, init, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOf`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Methods inherited from interface echopointng.able.Delegateable
`getRenderProperty, getRenderProperty`

Field Detail

### ACTION_LISTENERS_CHANGED_PROPERTY

    public static final java.lang.String ACTION_LISTENERS_CHANGED_PROPERTY

See Also:
  Constant Field Values

### DEFAULT_STYLE

    public static Style DEFAULT_STYLE

### DOCUMENT_CHANGED_PROPERTY

    public static final java.lang.String DOCUMENT_CHANGED_PROPERTY

See Also:
  Constant Field Values

### INPUT_TRANSFER

    public static final java.lang.String INPUT_TRANSFER

See Also:
  Constant Field Values

### PROPERTY_ACTION_COMMAND

    public static final java.lang.String PROPERTY_ACTION_COMMAND

See Also:
  Constant Field Values

### PROPERTY_BUTTON_BACKGROUND

    public static final java.lang.String PROPERTY_BUTTON_BACKGROUND

See Also:
  Constant Field Values

### PROPERTY_BUTTON_OPERATOR_FOREGROUND

    public static final java.lang.String PROPERTY_BUTTON_OPERATOR_FOREGROUND

See Also:
  Constant Field Values

### PROPERTY_BUTTON_NUMBER_FOREGROUND

    public static final java.lang.String PROPERTY_BUTTON_NUMBER_FOREGROUND

See Also:
  Constant Field Values

### PROPERTY_BUTTON_HEIGHT

    public static final java.lang.String PROPERTY_BUTTON_HEIGHT

See Also:
  Constant Field Values

### PROPERTY_BUTTON_WIDTH

    public static final java.lang.String PROPERTY_BUTTON_WIDTH

See Also:
  Constant Field Values

### PROPERTY_DISPLAY_BACKGROUND

    public static final java.lang.String PROPERTY_DISPLAY_BACKGROUND

See Also:
  Constant Field Values

### PROPERTY_DISPLAY_FONT

    public static final java.lang.String PROPERTY_DISPLAY_FONT

See Also:
  Constant Field Values

### PROPERTY_DISPLAY_FOREGROUND

    public static final java.lang.String PROPERTY_DISPLAY_FOREGROUND

See Also:
  Constant Field Values

### PROPERTY_MEMORY

    public static final java.lang.String PROPERTY_MEMORY

See Also:
  Constant Field Values

### PROPERTY_TRANSFER

    public static final java.lang.String PROPERTY_TRANSFER

See Also:
  Constant Field Values

### TEXT_CHANGED_PROPERTY

    public static java.lang.String TEXT_CHANGED_PROPERTY

### DEFAULT_NUMBER_MASK

    public static final java.lang.String DEFAULT_NUMBER_MASK

See Also:
  Constant Field Values

Constructor Detail

### Calculator

    public Calculator()

  Constructs a `Calculator`

### Calculator

    public Calculator(Document document)

  Constructs a `Calculator` with the specified backing Document

  Parameters:
    `document` - - the backing Document

Method Detail

### addActionListener

    public void addActionListener(ActionListener l)

  Adds an `ActionListener` to the `Calculator`. The `ActionListener` will be invoked when the user presses the Transfer button in the calculator.

  Parameters:
    `l` - the `ActionListener` to add

### getActionCommand

    public java.lang.String getActionCommand()

  Returns the action command which will be provided in `ActionEvent` s fired by this `Calculator`.

  Returns:
    the action command

### getButtonBackground

    public Color getButtonBackground()

  Returns:
    the background color of the calculator's buttons

### getButtonOperatorForegound

    public Color getButtonOperatorForegound()

  Returns:
    the foregound color of the calculator's buttons that are operators

### getButtonNumberForeground

    public Color getButtonNumberForeground()

  Returns:
    the foregound color of the calculator's buttons that are operators

### getButtonHeight

    public Extent getButtonHeight()

  Returns:
    the height of the calculator's buttons

### getButtonWidth

    public Extent getButtonWidth()

  Returns:
    the width of the calculator's buttons

### getDisplayBackground

    public Color getDisplayBackground()

  Returns:
    the background color of the calculator's number display

### getDisplayFont

    public Font getDisplayFont()

  Returns:
    the font of the calculator's number display

### getDisplayForeground

    public Color getDisplayForeground()

  Returns:
    the foreground color of the calculator's number display

### getDocument

    public Document getDocument()

  Returns the model associated with this `TextComponent`.

  Returns:
    the model

### getMemory

    public java.lang.String getMemory()

  Returns:
    the state of the calculator's memory

### getTransfer

    public java.lang.String getTransfer()

  Returns:
    the text for the of the calculator's transfer button
  See Also:
    `setTransfer(String)`

### getText

    public java.lang.String getText()

  Returns the text contained in the `Document` model of this text component.

  Returns:
    the text contained in the document

### hasActionListeners

    public boolean hasActionListeners()

  Determines the any `ActionListener` s are registered.

  Returns:
    true if any action listeners are registered

### processInput

    public void processInput(java.lang.String inputName,
                             java.lang.Object inputValue)

  Description copied from class: `Component`
  Processes client input specific to the `Component` received from the `UpdateManager`. Derivative implementations should take care to invoke `super.processInput()`.

  Overrides:
    `processInput` in class `Component`
  Parameters:
    `inputName` - the name of the input
    `inputValue` - the value of the input
  See Also:
    `Component.processInput(java.lang.String, java.lang.Object)`

### removeActionListener

    public void removeActionListener(ActionListener l)

  Removes an `ActionListener` from the `Calculator`.

  Parameters:
    `l` - the `ActionListener` to remove

### setActionCommand

    public void setActionCommand(java.lang.String newValue)

  Sets the action command which will be provided in `ActionEvent` s fired by this `Calculator`.

  Parameters:
    `newValue` - the new action command

### setButtonBackground

    public void setButtonBackground(Color newValue)

  Sets the background color of the calculator's buttons

  Parameters:
    `newValue` - - the new value

### setButtonOperatorForeground

    public void setButtonOperatorForeground(Color newValue)

  Sets the foreground color of the calculator's buttons that are operators

  Parameters:
    `newValue` - - the new value

### setButtonNumberForeground

    public void setButtonNumberForeground(Color newValue)

  Sets the foreground color of the calculator's buttons that are numbers

  Parameters:
    `newValue` - - the new value

### setButtonHeight

    public void setButtonHeight(Extent newValue)

  Sets the height of the calculator's buttons

  Parameters:
    `newValue` - - the new value

### setButtonWidth

    public void setButtonWidth(Extent newValue)

  Sets the width of the calculator's buttons

  Parameters:
    `newValue` - - the new value

### setDisplayBackground

    public void setDisplayBackground(Color newValue)

  Sets the background color of the calculator's number display

  Parameters:
    `newValue` - - the new value

### setDisplayFont

    public void setDisplayFont(Font newValue)

  Sets the font of the calculator's number display

  Parameters:
    `newValue` - - the new value

### setDisplayForeground

    public void setDisplayForeground(Color newValue)

  Sets the foreground color of the calculator's number display

  Parameters:
    `newValue` - - the new value

### setDocument

    public void setDocument(Document newValue)

  Sets the model associated with this `TextComponent`.

  Parameters:
    `newValue` - the new model (may not be null)

### isValidNumber

    public boolean isValidNumber(java.lang.String numberText)

  This method is called to determine wether the text parameter is a valid number to be placed inside the calculator or its memory.

  Parameters:
    `numberText` - - the text to check
  Returns:
    true if its a valid number.

### setMemory

    public void setMemory(java.lang.String newValue)

  Sets the string value into the calculators memory

  Parameters:
    `newValue` -

### setTransfer

    public void setTransfer(java.lang.String newValue)

  Sets the string value for the Transfer button. If this is non-null then a Transfer button is drawn and it can be used to raise an action event for the Calculator. If it is null then it no Transfer button is drawn and no action event can be raised by the Calulator

  Parameters:
    `newValue` -

### setText

    public void setText(java.lang.String newValue)

  Sets the text of the document model of this calculaor. It will call isValidNumber first and if this returns false then an IllegalArgumentException will be thrown.

  Parameters:
    `newValue` - the new text
  Throws:
    `java.lang.IllegalArgumentException` - - if the text cannot be converted into a number that the calculator can handle.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD