com.jp.comp.calculator
Class CalculatorField

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bydev.gui.field.PopupField
                      extended bycom.jp.comp.calculator.CalculatorField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, CalculatorListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable

public class CalculatorField
extends dev.gui.field.PopupField
implements CalculatorListener, java.awt.event.ActionListener, java.beans.PropertyChangeListener

CalculatorField represents a field to enter a number value, formatted with specified Locale, and with popup CalculatorPanel

See Also:
CalculatorPanel, Serialized Form

Nested Class Summary
protected  class CalculatorField.NumberFormatterExt
          Extends NumberFormatter to allow processing null or empty value
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static javax.swing.KeyStroke DEFAULT_POPUP_CALCULATOR_HOTKEY
          Default hot key to popup the MonthCalendarPanel (Down Arrow)
protected  double fBufferedResult
           
protected  CalculatorEvent fCalculatorEvent
           
protected  boolean fCopyValueToPupupCalculator
           
protected  boolean fFreezeDocListener
           
protected  java.text.DecimalFormat fNumberFormatter
           
protected  CalculatorPanel pnlCalculator
           
protected static java.lang.String POPUP_CALCULATOR_ACTION_NAME
           
static java.lang.String PROPERTY_COPY_VALUE_TO_POPUP_CALCULATOR
          Property name for the copyValueToPupupCalculator property
static java.lang.String PROPERTY_POPUP_HOTKEY
          Property name for the popupHotKey property
 
Fields inherited from class dev.gui.field.PopupField
btnPopup, DEFAULT_BUTTON_TEXT, fField, fSelectAllFocusAdapter, pnlPopup, popupMenu, PROPERTY_FIELD, PROPERTY_FIELD_ENABLED, PROPERTY_POPUP_BUTTON_ENABLED, PROPERTY_POPUP_BUTTON_ICON, PROPERTY_POPUP_BUTTON_TEXT, PROPERTY_POPUP_BUTTON_TOOLTIP_TEXT, PROPERTY_POPUP_PANEL, PROPERTY_TOOLTIP_TEXT
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CalculatorField()
          Constructs the CalculatorField with default Locale
CalculatorField(java.util.Locale aLocale)
          Constructs the CalculatorField with specified Locale
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent anEvent)
          Catches action events comming from CalculatorPanel and closes popup calculator when equal button is pressed
 void addCalculatorListener(CalculatorListener aListener)
          Adds Calculator's listener
protected  void beforeShowPopup()
           
 void clearField()
          Clear the field setting null to it
 void fractionDigitsChanged(CalculatorEvent anEvent)
          Invoked when a change in the number of fraction digits occurs
 java.lang.String getAbout()
           
 CalculatorPanel getCalculator()
          Returns the CalculatorPanel instance
 java.awt.Color getDisplayBackground()
          Gets display's background Color in the popup CalculatorPanel
 java.awt.Font getDisplayFont()
          Gets display's font Color in the popup CalculatorPanel
 java.awt.Color getDisplayForeground()
          Gets display's foreground Color in the popup CalculatorPanel
 int getFractionDigits()
          Gets the number of fraction digits in the popup CalculatorPanel
 java.awt.Color getFractionDigitsBackground()
          Gets display's background Color in the popup CalculatorPanel
 java.awt.Color getFractionDigitsForeground()
          Gets display's foreground Color in the popup CalculatorPanel
 java.text.DecimalFormat getNumberFormatter()
          Returns being used number formatter to format entering number
 javax.swing.KeyStroke getPopupCalendarHotKey()
          Returns hot key for popup CalculatorPanel
 java.awt.Dimension getPreferredSize()
           
 double getValue()
          Returns field's value
 boolean isCopyValueToPupupCalculator()
          Returns true if field's value sould be copied to popup calculator when it's being popped up
 boolean isFieldEmpty()
          Returns true if the field is empty
 boolean isGroupingUsed()
          Returns true if number grouping is used in the popup CalculatorPanel
 boolean isShowFractionTrailingZeros()
          Returns true if fraction trailing zeros should by shown depending on the value of the property number of fraction digits
 void propertyChange(java.beans.PropertyChangeEvent anEvent)
          Forwards property change events comming from CalculatorPanel
 void removeCalculatorListener(CalculatorListener aListener)
          Removes Calculator's listener
 void resultChanged(CalculatorEvent anEvent)
          Catches event result changed comming from CalculatorPanel to show the result on the display
 void setAbout(java.lang.String aAbout)
           
 void setCopyValueToPupupCalculator(boolean aFlag)
          Sets true if field's value sould be copied to popup calculator when it's being popped up
 void setDisplayBackground(java.awt.Color aColor)
          Sets display's background Color in the popup CalculatorPanel
 void setDisplayFont(java.awt.Font aFont)
          Sets display's font Color in the popup CalculatorPanel
 void setDisplayForeground(java.awt.Color aColor)
          Sets display's foreground Color in the popup CalculatorPanel
 void setFractionDigits(int aValue)
          Sets the specified number of fraction digits in the popup CalculatorPanel
 void setFractionDigitsBackground(java.awt.Color aColor)
          Sets fraction digits's background Color in the popup CalculatorPanel
 void setFractionDigitsForeground(java.awt.Color aColor)
          Sets fraction digits's foreground Color in the popup CalculatorPanel
 void setGroupingUsed(boolean aFlag)
          Set to true if number grouping should be used in the popup CalculatorPanel
 void setLocale(java.util.Locale aLocale)
          Sets a new Calculator's Locale.
 void setPopupCalendarHotKey(javax.swing.KeyStroke aKeyStroke)
          Assigns a new hot key to pop up CalculatorPanel
 void setShowFractionTrailingZeros(boolean aFlag)
          Sets true if fraction trailing zeros should by shown depending on the value of the property number of fraction digits
 void setValue(double aValue)
          Sets a new value to the field
 
Methods inherited from class dev.gui.field.PopupField
btnPopup_actionPerformed, fieldFocusGained, getField, getPopupButton, getPopupButtonIcon, getPopupButtonText, getPopupButtonToolTipText, getPopupPanel, getToolTipText, initPopup, isEnabled, isFieldEnabled, isPopupButtonEnabled, requestFocus, setEnabled, setField, setFieldEnabled, setPopupButtonEnabled, setPopupButtonIcon, setPopupButtonText, setPopupButtonToolTipText, setPopupPanel, setToolTipText
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_POPUP_HOTKEY

public static final java.lang.String PROPERTY_POPUP_HOTKEY
Property name for the popupHotKey property

See Also:
Constant Field Values

PROPERTY_COPY_VALUE_TO_POPUP_CALCULATOR

public static final java.lang.String PROPERTY_COPY_VALUE_TO_POPUP_CALCULATOR
Property name for the copyValueToPupupCalculator property

See Also:
Constant Field Values

DEFAULT_POPUP_CALCULATOR_HOTKEY

public static final javax.swing.KeyStroke DEFAULT_POPUP_CALCULATOR_HOTKEY
Default hot key to popup the MonthCalendarPanel (Down Arrow)


POPUP_CALCULATOR_ACTION_NAME

protected static final java.lang.String POPUP_CALCULATOR_ACTION_NAME
See Also:
Constant Field Values

fNumberFormatter

protected java.text.DecimalFormat fNumberFormatter

pnlCalculator

protected CalculatorPanel pnlCalculator

fCalculatorEvent

protected CalculatorEvent fCalculatorEvent

fCopyValueToPupupCalculator

protected boolean fCopyValueToPupupCalculator

fBufferedResult

protected double fBufferedResult

fFreezeDocListener

protected boolean fFreezeDocListener
Constructor Detail

CalculatorField

public CalculatorField()
Constructs the CalculatorField with default Locale


CalculatorField

public CalculatorField(java.util.Locale aLocale)
Constructs the CalculatorField with specified Locale

Parameters:
aLocale - the Locale
Method Detail

beforeShowPopup

protected void beforeShowPopup()

clearField

public void clearField()
Clear the field setting null to it


isCopyValueToPupupCalculator

public boolean isCopyValueToPupupCalculator()
Returns true if field's value sould be copied to popup calculator when it's being popped up

Returns:
true if field's value sould be copied to popup calculator

setCopyValueToPupupCalculator

public void setCopyValueToPupupCalculator(boolean aFlag)
Sets true if field's value sould be copied to popup calculator when it's being popped up

Parameters:
aFlag - true if field's value sould be copied to popup calculator

isShowFractionTrailingZeros

public boolean isShowFractionTrailingZeros()
Returns true if fraction trailing zeros should by shown depending on the value of the property number of fraction digits

Returns:
true if fraction trailing zeros should by shown

setShowFractionTrailingZeros

public void setShowFractionTrailingZeros(boolean aFlag)
Sets true if fraction trailing zeros should by shown depending on the value of the property number of fraction digits

Parameters:
aFlag - true if fraction trailing zeros should by shown

getCalculator

public CalculatorPanel getCalculator()
Returns the CalculatorPanel instance

Returns:
the CalculatorPanel instance

getPopupCalendarHotKey

public javax.swing.KeyStroke getPopupCalendarHotKey()
Returns hot key for popup CalculatorPanel

Returns:
hot key for popup CalculatorPanel

setPopupCalendarHotKey

public void setPopupCalendarHotKey(javax.swing.KeyStroke aKeyStroke)
Assigns a new hot key to pop up CalculatorPanel

Parameters:
aKeyStroke - a new hot key

setLocale

public void setLocale(java.util.Locale aLocale)
Sets a new Calculator's Locale. The change of the Calculator's Locale will/may change the buttons text, messages text and the result and edit format. By default Default Locale is used

Parameters:
aLocale - a new Calculator's Locale

getValue

public double getValue()
Returns field's value

Returns:
field's value

setValue

public void setValue(double aValue)
Sets a new value to the field

Parameters:
aValue - a new value

isFieldEmpty

public boolean isFieldEmpty()
Returns true if the field is empty

Returns:
true if the field is empty

getFractionDigits

public int getFractionDigits()
Gets the number of fraction digits in the popup CalculatorPanel

Returns:
the number of fraction digits

setFractionDigits

public void setFractionDigits(int aValue)
Sets the specified number of fraction digits in the popup CalculatorPanel

Parameters:
aValue - the specified number of fraction digits

getDisplayForeground

public java.awt.Color getDisplayForeground()
Gets display's foreground Color in the popup CalculatorPanel

Returns:
display's foreground Color

setDisplayForeground

public void setDisplayForeground(java.awt.Color aColor)
Sets display's foreground Color in the popup CalculatorPanel

Parameters:
aColor - display's foreground Color

getDisplayBackground

public java.awt.Color getDisplayBackground()
Gets display's background Color in the popup CalculatorPanel

Returns:
display's background Color

setDisplayBackground

public void setDisplayBackground(java.awt.Color aColor)
Sets display's background Color in the popup CalculatorPanel

Parameters:
aColor - display's background Color

getDisplayFont

public java.awt.Font getDisplayFont()
Gets display's font Color in the popup CalculatorPanel

Returns:
display's font Color

setDisplayFont

public void setDisplayFont(java.awt.Font aFont)
Sets display's font Color in the popup CalculatorPanel

Parameters:
aFont - display's font Color

getFractionDigitsForeground

public java.awt.Color getFractionDigitsForeground()
Gets display's foreground Color in the popup CalculatorPanel

Returns:
display's foreground Color

setFractionDigitsForeground

public void setFractionDigitsForeground(java.awt.Color aColor)
Sets fraction digits's foreground Color in the popup CalculatorPanel

Parameters:
aColor - fraction digits's foreground Color

getFractionDigitsBackground

public java.awt.Color getFractionDigitsBackground()
Gets display's background Color in the popup CalculatorPanel

Returns:
display's background Color

setFractionDigitsBackground

public void setFractionDigitsBackground(java.awt.Color aColor)
Sets fraction digits's background Color in the popup CalculatorPanel

Parameters:
aColor - fraction digits's background Color

isGroupingUsed

public boolean isGroupingUsed()
Returns true if number grouping is used in the popup CalculatorPanel

Returns:
true if number grouping is used

setGroupingUsed

public void setGroupingUsed(boolean aFlag)
Set to true if number grouping should be used in the popup CalculatorPanel

Parameters:
aFlag - true if number grouping should be used

getNumberFormatter

public java.text.DecimalFormat getNumberFormatter()
Returns being used number formatter to format entering number

Returns:
being used number formatter

getAbout

public java.lang.String getAbout()

setAbout

public void setAbout(java.lang.String aAbout)

fractionDigitsChanged

public void fractionDigitsChanged(CalculatorEvent anEvent)
Description copied from interface: CalculatorListener
Invoked when a change in the number of fraction digits occurs

Specified by:
fractionDigitsChanged in interface CalculatorListener
Parameters:
anEvent - copy of the class event

resultChanged

public void resultChanged(CalculatorEvent anEvent)
Catches event result changed comming from CalculatorPanel to show the result on the display

Specified by:
resultChanged in interface CalculatorListener
Parameters:
anEvent - CalculatorEvent

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent anEvent)
Catches action events comming from CalculatorPanel and closes popup calculator when equal button is pressed

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
anEvent - ActionEvent

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent anEvent)
Forwards property change events comming from CalculatorPanel

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
anEvent - PropertyChangeEvent

addCalculatorListener

public void addCalculatorListener(CalculatorListener aListener)
Adds Calculator's listener

Parameters:
aListener - Calculator's listener

removeCalculatorListener

public void removeCalculatorListener(CalculatorListener aListener)
Removes Calculator's listener

Parameters:
aListener - Calculator's listener

getPreferredSize

public java.awt.Dimension getPreferredSize()