Class JMeter

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.text.JTextComponent
                          |
                          +--javax.swing.JTextField
                                |
                                +--JMeter

public class JMeter
extends javax.swing.JTextField

Component: JMeter Displays numbers in a textbox with correct decimal format. Target user cannot modify the component. Behaves exactly like a JTextField, except the setText() method has been disabled.

Version:
2.0 22 Nov 1999
Author:
Raymond Li
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JTextField
javax.swing.JTextField.AccessibleJTextField
 
Inner classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JMeter()
          Default constructor (parameter-less).
JMeter(java.awt.Color bg, java.awt.Color fg)
          Constructor with user-defined background and foreground.
JMeter(int leftAccuracy, int rightAccuracy)
          Constructor with user-defined left and right of decimal accuracy.
JMeter(int leftAccuracy, int rightAccuracy, java.awt.Color bg, java.awt.Color fg)
          Constructor with user-defined accuracy and colors.
 
Method Summary
 int getLeftAccuracy()
          Accessor for number left accuracy.
 int getRightAccuracy()
          Accessor for right accuracy.
protected  void Init()
          Initializations common to all constructors.
protected  void processComponentKeyEvent(java.awt.event.KeyEvent event)
          Disallows special key input.
protected  void processInputMethodEvent(java.awt.event.InputMethodEvent event)
          Disallows normal user input.
 void redrawMeter()
          Redraws the meter.
 void resetMeter()
          Meter is zero'ed.
 void setLeftAccuracy(int n)
          Mutator for left accuracy.
 void setRightAccuracy(int n)
          Mutator for left accuracy.
 void setText(java.lang.String s)
          Disabled for safety purposes.
 void setValue(double num)
          Set the value of the meter using data of type double.
 void setValue(int num)
          Set the value of the meter using data of type int.
 void setValue(long num)
          Set the value of the meter using data of type long.
 void setValue(short num)
          Set the value of the meter using data of type short.
 
Methods inherited from class javax.swing.JTextField
addActionListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretPosition, getDisabledTextColor, getDocument, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getUI, isEditable, isFocusTraversable, isOpaque, loadKeymap, modelToView, moveCaretPosition, paste, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setDocument, setEditable, setEnabled, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setOpaque, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JMeter

public JMeter()
Default constructor (parameter-less).

JMeter

public JMeter(java.awt.Color bg,
              java.awt.Color fg)
Constructor with user-defined background and foreground.
Parameters:
bg - initial background color
fg - initial foreground color, color of text

JMeter

public JMeter(int leftAccuracy,
              int rightAccuracy)
Constructor with user-defined left and right of decimal accuracy.
Parameters:
leftAccuracy - accuracy of digits to the left of decimal
rightAccuracy - accuracy of digits to the right of decimal

JMeter

public JMeter(int leftAccuracy,
              int rightAccuracy,
              java.awt.Color bg,
              java.awt.Color fg)
Constructor with user-defined accuracy and colors.
Parameters:
leftAccuracy - accuracy of digits to the left of decimal
rightAccuracy - accuracy of digits to the right of decimal
bg - initial background color
fg - initial foreground color, color of text
Method Detail

Init

protected void Init()
Initializations common to all constructors.

getLeftAccuracy

public int getLeftAccuracy()
Accessor for number left accuracy.
Returns:
the maximum number of digits to left of decimal

getRightAccuracy

public int getRightAccuracy()
Accessor for right accuracy.
Returns:
the maximum number of digits to right of decimal

setLeftAccuracy

public void setLeftAccuracy(int n)
Mutator for left accuracy.

setRightAccuracy

public void setRightAccuracy(int n)
Mutator for left accuracy.

setText

public void setText(java.lang.String s)
Disabled for safety purposes.
Overrides:
setText in class javax.swing.text.JTextComponent

setValue

public void setValue(short num)
Set the value of the meter using data of type short.

setValue

public void setValue(int num)
Set the value of the meter using data of type int.

setValue

public void setValue(long num)
Set the value of the meter using data of type long.

setValue

public void setValue(double num)
Set the value of the meter using data of type double.

resetMeter

public void resetMeter()
Meter is zero'ed.

redrawMeter

public void redrawMeter()
Redraws the meter. When the user changes the accuracy of the number being displayed, the TextField (view) as well as the text inside must be re-calculated. This is basically the same code as the setValue() method, except due to changes in the left and/or right accuracy, the textfield needs to be resized.

processComponentKeyEvent

protected void processComponentKeyEvent(java.awt.event.KeyEvent event)
Disallows special key input.
Overrides:
processComponentKeyEvent in class javax.swing.text.JTextComponent

processInputMethodEvent

protected void processInputMethodEvent(java.awt.event.InputMethodEvent event)
Disallows normal user input.
Overrides:
processInputMethodEvent in class javax.swing.text.JTextComponent