com.jp.comp.calculator
Class CalculatorPanel

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

public class CalculatorPanel
extends javax.swing.JPanel
implements CalculatorListener, java.beans.PropertyChangeListener, java.awt.event.ContainerListener, java.awt.event.ActionListener

CalculatorPanel represents a standart calculator supplemented with memory register and possibility to change the number of fraction digits. The set of operation performed by the calculator can be changed by implementing one of the interfaces InputOperation or CalculatorOperation and adding it to the calculator

See Also:
Calculator, InputOperation, CalculatorOperation, Serialized Form

Nested Class Summary
static class CalculatorPanel.CalculatorButton
          Calculator's button with fixed size
 
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
protected  javax.swing.JButton btn0
           
protected  javax.swing.JButton btn1
           
protected  javax.swing.JButton btn2
           
protected  javax.swing.JButton btn3
           
protected  javax.swing.JButton btn4
           
protected  javax.swing.JButton btn5
           
protected  javax.swing.JButton btn6
           
protected  javax.swing.JButton btn7
           
protected  javax.swing.JButton btn8
           
protected  javax.swing.JButton btn9
           
protected  javax.swing.JButton btnAdd
           
protected  javax.swing.JButton btnBS
           
protected  javax.swing.JButton btnC
           
protected  javax.swing.JButton btnCE
           
protected  javax.swing.JButton btnDecSep
           
protected  javax.swing.JButton btnDiv
           
protected  javax.swing.JButton btnEqual
           
protected  javax.swing.JButton btnMC
           
protected  javax.swing.JButton btnMM
           
protected  javax.swing.JButton btnMP
           
protected  javax.swing.JButton btnMR
           
protected  javax.swing.JButton btnMS
           
protected  javax.swing.JButton btnMult
           
protected  javax.swing.JButton btnPercent
           
protected  javax.swing.JButton btnRecip
           
protected  javax.swing.JButton btnSign
           
protected  javax.swing.JButton btnSqrt
           
protected  javax.swing.JButton btnSub
           
static java.lang.String BUTTON_KEYSTROKE_1
          Property for the method putClientProperty for the button's keystroke
static java.lang.String BUTTON_KEYSTROKE_2
          Property for the method putClientProperty for the button's keystroke
static java.lang.String BUTTON_KEYSTROKE_3
          Property for the method putClientProperty for the button's keystroke
static java.lang.String DECIMAL_SEPARATOR
           
(package private) static java.awt.Dimension DEFAULT_DIMENSION
           
protected  javax.swing.JTextField edtDisplay
           
protected  javax.swing.JSpinner edtFractionDigits
           
protected  java.lang.String fBufferedDisplayValue
           
protected  double fBufferedResult
           
protected  java.util.HashMap fButtonKeys
           
protected  Calculator fCalculator
           
protected  CalculatorEvent fCalculatorEvent
           
protected  java.util.Vector fCalculatorListeners
           
protected  boolean fErrorHappend
           
protected  java.util.HashMap fInputOperations
           
protected  char fLocalizedDecimalSeparator
           
protected  char fLocalizedGroupingSeparator
           
protected  int fLocalizedGroupingSize
           
protected  java.lang.String fLocalizedMemorySymbol
           
protected  java.lang.String fLocalizedMinusSymbol
           
protected  java.text.DecimalFormat fNumberFormatter
           
protected  int fOldFractionDigits
           
static int FRACTION_DIGITS_DEFAULT_VALUE
          Default fraction digits value (2)
static int FRACTION_DIGITS_MAX_VALUE
          Max fraction digits value (11)
static int FRACTION_DIGITS_MIN_VALUE
          Min fraction digits value (0)
protected  boolean fShowFractionTrailingZeros
           
protected  boolean fValueChanged
           
static java.lang.String INPUT_0_KEY
          Input 0 key
static java.lang.String INPUT_1_KEY
          Input 1 key
static java.lang.String INPUT_2_KEY
          Input 2 key
static java.lang.String INPUT_3_KEY
          Input 3 key
static java.lang.String INPUT_4_KEY
          Input 4 key
static java.lang.String INPUT_5_KEY
          Input 5 key
static java.lang.String INPUT_6_KEY
          Input 6 key
static java.lang.String INPUT_7_KEY
          Input 7 key
static java.lang.String INPUT_8_KEY
          Input 8 key
static java.lang.String INPUT_9_KEY
          Input 9 key
static InputOperation INPUT_BS
          Default back space operation
static java.lang.String INPUT_BS_KEY
          Input back space key
static InputOperation INPUT_CLEAR
          Default display clear operation
static java.lang.String INPUT_CLEAR_KEY
          Input display clear key
static InputOperation INPUT_DECIMAL_SEPARATOR
          Default decimal separator operation
static java.lang.String INPUT_DECIMAL_SEPARATOR_KEY
          Input decimal separator key
static InputOperation INPUT_NIMBER
          Default input numbers operation
static InputOperation INPUT_SIGN
          Default sign operation
static java.lang.String INPUT_SIGN_KEY
          Input sign key
protected  javax.swing.JLabel lblMemory
           
static int MAX_INPUT_FRACTION_DIGITS
           
static java.lang.String MINUS_SYMBOL
           
static java.lang.String PROPERTY_CALCULATOR
          Property name for the calculator property
static java.lang.String PROPERTY_DISPLAY_BACKGROUND
          Property name for the displayBackground property
static java.lang.String PROPERTY_DISPLAY_FONT
          Property name for the displayFont property
static java.lang.String PROPERTY_DISPLAY_FOREGROUND
          Property name for the displayForeground property
static java.lang.String PROPERTY_FRACTION_DIGITS
          Property name for the fractionDigits property
static java.lang.String PROPERTY_FRACTION_DIGITS_BACKGROUND
          Property name for the fractionDigitsBackground property
static java.lang.String PROPERTY_FRACTION_DIGITS_FOREGROUND
          Property name for the fractionDigitsForeground property
static java.lang.String PROPERTY_GROUPING_USED
          Property name for the groupingUsed property
static java.lang.String PROPERTY_SHOW_FRACTION_TRAILING_ZEROS
          Property name for the showFractionTrailingZeros property
 
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
CalculatorPanel()
          Constructs a new Calculator with default Locale
CalculatorPanel(java.util.Locale aLocale)
          Constructs a new Calculator with specified Locale
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addActionListener(java.awt.event.ActionListener aListener)
          Adds action listener
 void addCalculatorListener(CalculatorListener aListener)
          Adds Calculator's listener
 void addInputOperation(java.lang.String anOperationKey, InputOperation anInputOperation)
          Adds a new input operation to the calculator panel.
 void beforeShow()
          This method is used be CalculatorField to clear the calculator before to pop it up
protected  void button_actionPerformed(java.awt.event.ActionEvent anEvent)
          Process buttons click
 void componentAdded(java.awt.event.ContainerEvent anEvent)
          Adds added button's KeyStroke to fButtonKeys
 void componentRemoved(java.awt.event.ContainerEvent anEvent)
          Removes removed button's KeyStroke from fButtonKeys
protected  void copyDisplayValueToClipboard()
          Copies display value to the clipboard
protected  void edtDisplay_keyPressed(java.awt.event.KeyEvent anEvent)
          Process pressed key
protected  void edtDisplay_keyTyped(java.awt.event.KeyEvent anEvent)
          Process typed key
(package private)  void edtFractionDigits_mousePressed(java.awt.event.MouseEvent e)
           
protected  void edtFractionDigits_stateChanged()
          When fraction digits value is changed it updates the result in the display
protected  void fireActionPerformed(java.awt.event.ActionEvent anEvent)
          Fired when calculator's button is pressed
protected  void fireFractionDigitsChanged()
          Fired when the fraction digits value is changed
protected  void fireResultChanged(CalculatorEvent anEvent)
          Fired when the result is calculated
protected  java.lang.String formatBufferedDisplayValue()
           
 void fractionDigitsChanged(CalculatorEvent anEvent)
          Invoked when a change in the number of fraction digits occurs
 java.lang.String getAbout()
           
 Calculator getCalculator()
          Returns current Calculator
 java.awt.Color getDisplayBackground()
          Gets display's background Color
 java.awt.Font getDisplayFont()
          Gets display's font Color
 java.awt.Color getDisplayForeground()
          Gets display's foreground Color
 double getDisplayValue()
          Gets double presentation of display value
 int getFractionDigits()
          Gets the number of fraction digits
 java.awt.Color getFractionDigitsBackground()
          Gets display's background Color
 java.awt.Color getFractionDigitsForeground()
          Gets display's foreground Color
 boolean isGroupingUsed()
          Returns true if number grouping is used
 boolean isInputOperationExist(java.lang.String anOperationKey)
          Returns true if input operation, specified by anOperationKey, exist
 boolean isShowFractionTrailingZeros()
          Returns true if fraction trailing zeros should by shown depending on the value of the property number of fraction digits
 boolean isValueChanged()
          Returns true if display value is changed by entering a new value
protected  void processCalculatorOperation(java.lang.String anActionCommand)
          Performs calculator operations
protected  void processInputOperation(java.lang.String anInputKey)
          Process input operations
protected  void processKey(javax.swing.KeyStroke aKeyStroke)
          Processes key
 void propertyChange(java.beans.PropertyChangeEvent anEvent)
          Catches and forwards property change events comming from Calculator to show memory sign when memory operation is performed
 void removeActionListener(java.awt.event.ActionListener aListener)
          Removes action listener
 void removeCalculatorListener(CalculatorListener aListener)
          Removes Calculator's listener
 void removeInputOperation(java.lang.String anOperationKey)
          Removes the input operation, specified by anOperationKey, from the calculator panel
 void requestFocus()
           
protected  void restoreDisplayValue()
          Restores display value
 void resultChanged(CalculatorEvent anEvent)
          Delegates the result is changed event form the Calculator
 void setAbout(java.lang.String aAbout)
           
 void setBufferedDisplayValue()
          Sets buffered string value to the display.
 void setCalculator(Calculator aCalculator)
          Sets a new Calculator to perform calculator's operations
 void setDisplayBackground(java.awt.Color aColor)
          Sets display's background Color
 void setDisplayFont(java.awt.Font aFont)
          Sets display's font Color
 void setDisplayForeground(java.awt.Color aColor)
          Sets display's foreground Color
 void setDisplayValue(double aValue)
          Sets a new display value
 void setFractionDigits(int aValue)
          Sets the specified number of fraction digits
 void setFractionDigitsBackground(java.awt.Color aColor)
          Sets fraction digits's background Color
 void setFractionDigitsForeground(java.awt.Color aColor)
          Sets fraction digits's foreground Color
 void setGroupingUsed(boolean aFlag)
          Sets to true if number grouping should be used
 void setLayout(java.awt.LayoutManager mgr)
           
 void setLocale(java.util.Locale aLocale)
          Sets a new Calculator's Locale.
 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 updateInputOperation(java.lang.String anOperationKey, InputOperation anInputOperation)
          Updates an existing input operation in the calculator panel.
 
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, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, 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, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, 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, 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, isEnabled, 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_DISPLAY_BACKGROUND

public static final java.lang.String PROPERTY_DISPLAY_BACKGROUND
Property name for the displayBackground property

See Also:
Constant Field Values

PROPERTY_DISPLAY_FOREGROUND

public static final java.lang.String PROPERTY_DISPLAY_FOREGROUND
Property name for the displayForeground property

See Also:
Constant Field Values

PROPERTY_DISPLAY_FONT

public static final java.lang.String PROPERTY_DISPLAY_FONT
Property name for the displayFont property

See Also:
Constant Field Values

PROPERTY_FRACTION_DIGITS_BACKGROUND

public static final java.lang.String PROPERTY_FRACTION_DIGITS_BACKGROUND
Property name for the fractionDigitsBackground property

See Also:
Constant Field Values

PROPERTY_FRACTION_DIGITS_FOREGROUND

public static final java.lang.String PROPERTY_FRACTION_DIGITS_FOREGROUND
Property name for the fractionDigitsForeground property

See Also:
Constant Field Values

PROPERTY_FRACTION_DIGITS

public static final java.lang.String PROPERTY_FRACTION_DIGITS
Property name for the fractionDigits property

See Also:
Constant Field Values

PROPERTY_GROUPING_USED

public static final java.lang.String PROPERTY_GROUPING_USED
Property name for the groupingUsed property

See Also:
Constant Field Values

PROPERTY_CALCULATOR

public static final java.lang.String PROPERTY_CALCULATOR
Property name for the calculator property

See Also:
Constant Field Values

PROPERTY_SHOW_FRACTION_TRAILING_ZEROS

public static final java.lang.String PROPERTY_SHOW_FRACTION_TRAILING_ZEROS
Property name for the showFractionTrailingZeros property

See Also:
Constant Field Values

BUTTON_KEYSTROKE_1

public static final java.lang.String BUTTON_KEYSTROKE_1
Property for the method putClientProperty for the button's keystroke

See Also:
Constant Field Values

BUTTON_KEYSTROKE_2

public static final java.lang.String BUTTON_KEYSTROKE_2
Property for the method putClientProperty for the button's keystroke

See Also:
Constant Field Values

BUTTON_KEYSTROKE_3

public static final java.lang.String BUTTON_KEYSTROKE_3
Property for the method putClientProperty for the button's keystroke

See Also:
Constant Field Values

INPUT_0_KEY

public static final java.lang.String INPUT_0_KEY
Input 0 key

See Also:
Constant Field Values

INPUT_1_KEY

public static final java.lang.String INPUT_1_KEY
Input 1 key

See Also:
Constant Field Values

INPUT_2_KEY

public static final java.lang.String INPUT_2_KEY
Input 2 key

See Also:
Constant Field Values

INPUT_3_KEY

public static final java.lang.String INPUT_3_KEY
Input 3 key

See Also:
Constant Field Values

INPUT_4_KEY

public static final java.lang.String INPUT_4_KEY
Input 4 key

See Also:
Constant Field Values

INPUT_5_KEY

public static final java.lang.String INPUT_5_KEY
Input 5 key

See Also:
Constant Field Values

INPUT_6_KEY

public static final java.lang.String INPUT_6_KEY
Input 6 key

See Also:
Constant Field Values

INPUT_7_KEY

public static final java.lang.String INPUT_7_KEY
Input 7 key

See Also:
Constant Field Values

INPUT_8_KEY

public static final java.lang.String INPUT_8_KEY
Input 8 key

See Also:
Constant Field Values

INPUT_9_KEY

public static final java.lang.String INPUT_9_KEY
Input 9 key

See Also:
Constant Field Values

INPUT_BS_KEY

public static final java.lang.String INPUT_BS_KEY
Input back space key

See Also:
Constant Field Values

INPUT_CLEAR_KEY

public static final java.lang.String INPUT_CLEAR_KEY
Input display clear key

See Also:
Constant Field Values

INPUT_DECIMAL_SEPARATOR_KEY

public static final java.lang.String INPUT_DECIMAL_SEPARATOR_KEY
Input decimal separator key

See Also:
Constant Field Values

INPUT_SIGN_KEY

public static final java.lang.String INPUT_SIGN_KEY
Input sign key

See Also:
Constant Field Values

INPUT_NIMBER

public static final InputOperation INPUT_NIMBER
Default input numbers operation


INPUT_BS

public static final InputOperation INPUT_BS
Default back space operation


INPUT_CLEAR

public static final InputOperation INPUT_CLEAR
Default display clear operation


INPUT_DECIMAL_SEPARATOR

public static final InputOperation INPUT_DECIMAL_SEPARATOR
Default decimal separator operation


INPUT_SIGN

public static final InputOperation INPUT_SIGN
Default sign operation


FRACTION_DIGITS_DEFAULT_VALUE

public static final int FRACTION_DIGITS_DEFAULT_VALUE
Default fraction digits value (2)

See Also:
Constant Field Values

FRACTION_DIGITS_MIN_VALUE

public static final int FRACTION_DIGITS_MIN_VALUE
Min fraction digits value (0)

See Also:
Constant Field Values

FRACTION_DIGITS_MAX_VALUE

public static final int FRACTION_DIGITS_MAX_VALUE
Max fraction digits value (11)

See Also:
Constant Field Values

DECIMAL_SEPARATOR

public static final java.lang.String DECIMAL_SEPARATOR
See Also:
Constant Field Values

MINUS_SYMBOL

public static final java.lang.String MINUS_SYMBOL
See Also:
Constant Field Values

MAX_INPUT_FRACTION_DIGITS

public static final int MAX_INPUT_FRACTION_DIGITS
See Also:
Constant Field Values

DEFAULT_DIMENSION

static final java.awt.Dimension DEFAULT_DIMENSION

edtDisplay

protected javax.swing.JTextField edtDisplay

lblMemory

protected javax.swing.JLabel lblMemory

btnMC

protected javax.swing.JButton btnMC

btnBS

protected javax.swing.JButton btnBS

btnCE

protected javax.swing.JButton btnCE

btnC

protected javax.swing.JButton btnC

edtFractionDigits

protected javax.swing.JSpinner edtFractionDigits

btnMR

protected javax.swing.JButton btnMR

btn7

protected javax.swing.JButton btn7

btn8

protected javax.swing.JButton btn8

btn9

protected javax.swing.JButton btn9

btnDiv

protected javax.swing.JButton btnDiv

btnSqrt

protected javax.swing.JButton btnSqrt

btnMS

protected javax.swing.JButton btnMS

btn4

protected javax.swing.JButton btn4

btn5

protected javax.swing.JButton btn5

btn6

protected javax.swing.JButton btn6

btnMult

protected javax.swing.JButton btnMult

btnPercent

protected javax.swing.JButton btnPercent

btnMP

protected javax.swing.JButton btnMP

btn1

protected javax.swing.JButton btn1

btn2

protected javax.swing.JButton btn2

btn3

protected javax.swing.JButton btn3

btnSub

protected javax.swing.JButton btnSub

btnRecip

protected javax.swing.JButton btnRecip

btnMM

protected javax.swing.JButton btnMM

btn0

protected javax.swing.JButton btn0

btnSign

protected javax.swing.JButton btnSign

btnDecSep

protected javax.swing.JButton btnDecSep

btnAdd

protected javax.swing.JButton btnAdd

btnEqual

protected javax.swing.JButton btnEqual

fInputOperations

protected java.util.HashMap fInputOperations

fBufferedDisplayValue

protected java.lang.String fBufferedDisplayValue

fBufferedResult

protected double fBufferedResult

fValueChanged

protected boolean fValueChanged

fShowFractionTrailingZeros

protected boolean fShowFractionTrailingZeros

fErrorHappend

protected boolean fErrorHappend

fNumberFormatter

protected java.text.DecimalFormat fNumberFormatter

fCalculator

protected Calculator fCalculator

fOldFractionDigits

protected int fOldFractionDigits

fButtonKeys

protected java.util.HashMap fButtonKeys

fLocalizedDecimalSeparator

protected char fLocalizedDecimalSeparator

fLocalizedGroupingSeparator

protected char fLocalizedGroupingSeparator

fLocalizedGroupingSize

protected int fLocalizedGroupingSize

fLocalizedMinusSymbol

protected java.lang.String fLocalizedMinusSymbol

fLocalizedMemorySymbol

protected java.lang.String fLocalizedMemorySymbol

fCalculatorEvent

protected CalculatorEvent fCalculatorEvent

fCalculatorListeners

protected transient java.util.Vector fCalculatorListeners
Constructor Detail

CalculatorPanel

public CalculatorPanel()
Constructs a new Calculator with default Locale


CalculatorPanel

public CalculatorPanel(java.util.Locale aLocale)
Constructs a new Calculator with specified Locale

Parameters:
aLocale - a new Calculator's Locale
Method Detail

setLayout

public void setLayout(java.awt.LayoutManager mgr)

edtFractionDigits_stateChanged

protected void edtFractionDigits_stateChanged()
When fraction digits value is changed it updates the result in the display


edtDisplay_keyTyped

protected void edtDisplay_keyTyped(java.awt.event.KeyEvent anEvent)
Process typed key

Parameters:
anEvent - typed key

edtDisplay_keyPressed

protected void edtDisplay_keyPressed(java.awt.event.KeyEvent anEvent)
Process pressed key

Parameters:
anEvent - pressed key

processKey

protected void processKey(javax.swing.KeyStroke aKeyStroke)
Processes key

Parameters:
aKeyStroke - KeyStroke

copyDisplayValueToClipboard

protected void copyDisplayValueToClipboard()
Copies display value to the clipboard


button_actionPerformed

protected void button_actionPerformed(java.awt.event.ActionEvent anEvent)
Process buttons click

Parameters:
anEvent - the event info

processInputOperation

protected void processInputOperation(java.lang.String anInputKey)
Process input operations

Parameters:
anInputKey - action command

processCalculatorOperation

protected void processCalculatorOperation(java.lang.String anActionCommand)
Performs calculator operations

Parameters:
anActionCommand - action command

requestFocus

public void requestFocus()

beforeShow

public void beforeShow()
This method is used be CalculatorField to clear the calculator before to pop it up


restoreDisplayValue

protected void restoreDisplayValue()
Restores display value


formatBufferedDisplayValue

protected java.lang.String formatBufferedDisplayValue()

getDisplayValue

public double getDisplayValue()
Gets double presentation of display value

Returns:
display value

setBufferedDisplayValue

public void setBufferedDisplayValue()
Sets buffered string value to the display. Used only for inputing value


setDisplayValue

public void setDisplayValue(double aValue)
Sets a new display value

Parameters:
aValue - a new display value

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

isValueChanged

public boolean isValueChanged()
Returns true if display value is changed by entering a new value

Returns:
true if display value is changed

getFractionDigits

public int getFractionDigits()
Gets the number of fraction digits

Returns:
the number of fraction digits

setFractionDigits

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

Parameters:
aValue - the specified number of fraction digits

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 format. By default Default Locale is used

Parameters:
aLocale - a new Calculator's Locale

getDisplayForeground

public java.awt.Color getDisplayForeground()
Gets display's foreground Color

Returns:
display's foreground Color

setDisplayForeground

public void setDisplayForeground(java.awt.Color aColor)
Sets display's foreground Color

Parameters:
aColor - display's foreground Color

getDisplayBackground

public java.awt.Color getDisplayBackground()
Gets display's background Color

Returns:
display's background Color

setDisplayBackground

public void setDisplayBackground(java.awt.Color aColor)
Sets display's background Color

Parameters:
aColor - display's background Color

getDisplayFont

public java.awt.Font getDisplayFont()
Gets display's font Color

Returns:
display's font Color

setDisplayFont

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

Parameters:
aFont - display's font Color

getFractionDigitsForeground

public java.awt.Color getFractionDigitsForeground()
Gets display's foreground Color

Returns:
display's foreground Color

setFractionDigitsForeground

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

Parameters:
aColor - fraction digits's foreground Color

getFractionDigitsBackground

public java.awt.Color getFractionDigitsBackground()
Gets display's background Color

Returns:
display's background Color

setFractionDigitsBackground

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

Parameters:
aColor - fraction digits's background Color

isGroupingUsed

public boolean isGroupingUsed()
Returns true if number grouping is used

Returns:
true if number grouping is used

setGroupingUsed

public void setGroupingUsed(boolean aFlag)
Sets to true if number grouping should be used

Parameters:
aFlag - true if number grouping should be used

getCalculator

public Calculator getCalculator()
Returns current Calculator

Returns:
current Calculator

setCalculator

public void setCalculator(Calculator aCalculator)
Sets a new Calculator to perform calculator's operations

Parameters:
aCalculator - a new Calculator

getAbout

public java.lang.String getAbout()

setAbout

public void setAbout(java.lang.String aAbout)

addInputOperation

public void addInputOperation(java.lang.String anOperationKey,
                              InputOperation anInputOperation)
Adds a new input operation to the calculator panel. If anOperationKey already exist IllegalArgumentException will be thrown

Parameters:
anOperationKey - operation key
anInputOperation - input operation
Throws:
java.lang.IllegalArgumentException

updateInputOperation

public void updateInputOperation(java.lang.String anOperationKey,
                                 InputOperation anInputOperation)
Updates an existing input operation in the calculator panel. If anOperationKey doesn't exist IllegalArgumentException will be thrown

Parameters:
anOperationKey - operation key
anInputOperation - input operation
Throws:
java.lang.IllegalArgumentException

removeInputOperation

public void removeInputOperation(java.lang.String anOperationKey)
Removes the input operation, specified by anOperationKey, from the calculator panel

Parameters:
anOperationKey - operation key

isInputOperationExist

public boolean isInputOperationExist(java.lang.String anOperationKey)
Returns true if input operation, specified by anOperationKey, exist

Parameters:
anOperationKey - operation key
Returns:
true if operation exist

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)
Delegates the result is changed event form the Calculator

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

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent anEvent)
Catches and forwards property change events comming from Calculator to show memory sign when memory operation is performed

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

componentAdded

public void componentAdded(java.awt.event.ContainerEvent anEvent)
Adds added button's KeyStroke to fButtonKeys

Specified by:
componentAdded in interface java.awt.event.ContainerListener
Parameters:
anEvent - ContainerEvent

componentRemoved

public void componentRemoved(java.awt.event.ContainerEvent anEvent)
Removes removed button's KeyStroke from fButtonKeys

Specified by:
componentRemoved in interface java.awt.event.ContainerListener
Parameters:
anEvent - ContainerEvent

fireResultChanged

protected void fireResultChanged(CalculatorEvent anEvent)
Fired when the result is calculated

Parameters:
anEvent - CalculatorEvent

fireFractionDigitsChanged

protected void fireFractionDigitsChanged()
Fired when the fraction digits value is changed


fireActionPerformed

protected void fireActionPerformed(java.awt.event.ActionEvent anEvent)
Fired when calculator's button is pressed

Parameters:
anEvent - the ActionEvent

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

addActionListener

public void addActionListener(java.awt.event.ActionListener aListener)
Adds action listener

Parameters:
aListener - action listener

removeActionListener

public void removeActionListener(java.awt.event.ActionListener aListener)
Removes action listener

Parameters:
aListener - action listener

edtFractionDigits_mousePressed

void edtFractionDigits_mousePressed(java.awt.event.MouseEvent e)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener