adm
Class CTextField

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
              |
              +--java.awt.TextField
                    |
                    +--adm.CTextField

public class CTextField
extends java.awt.TextField
implements CInterface, CConstants, DeviceListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.ActionListener, java.lang.Runnable

CTextField is an awt component bean. It is used to control and monitor a value of the specified device property in the control system. Its size, bound, foreground, background and the font can be set by the user.

The color of the text will be the same as the foreground if the color mode is set to CLRMOD_STATIC (default). When the color mode is set to CLRMOD_ALARM the color of the text will change to yellow or red if the property is in a warning or alarm state (determined by warning and alarm limits).

The display value can be formatted following C "printf" conventions, or use one of following static format constants:

  1. FRMT_INTEGER (%d)
  2. FRMT_FLOAT (%.3f)
  3. FRMT_SCIENTIFIC (%.3e)
  4. FRMT_AUTO (%.3g)
  5. FRMT_HEX (%#x)
  6. FRMT_OCTAL (%#o)
The default format is FRMT_AUTO which means the value will display as a float number or scientific notation depending on the value.

When the cursor is focused on the widget, the monitor (live update) will stop. If no action from user occurs within 5 seconds, the live update will start again. This 5 second counter will restart after each key stroke delivered to the widget.

Since:
adm0.1
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface adm.CConstants
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, AXIS_BOTTOM, AXIS_LEFT, AXIS_RIGHT, AXIS_STYLE_LINEAR, AXIS_STYLE_LOG10, AXIS_TOP, CLASS_QUERY, CLRMOD_ALARM, CLRMOD_STATIC, COLUMN, DEVICE_QUERY, DIR_DOWN, DIR_LEFT, DIR_RIGHT, DIR_UP, FILL_FROM_CENTER, FILL_FROM_EDGE, FRMT_AUTO, FRMT_FLOAT, FRMT_HEX, FRMT_INTEGER, FRMT_OCTAL, FRMT_SCIENTIFIC, HORIZONTAL, LABEL_ALL, LABEL_AXIS, LABEL_NONE, LABEL_VALUE, PROPERTY_QUERY, RANGE_AUTO, RANGE_FROM_PROPERTY, RANGE_STATIC, ROW, STYLE_FILLUNDER, STYLE_LINE, STYLE_POINT, VERTICAL
 
Constructor Summary
CTextField()
          Null Constructor
CTextField(java.lang.String dName, java.lang.String pName)
          Null constructor with device name and property name
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          Send the new value to the control system and resume monitoring
 void deviceChanged(DeviceEvent evt)
           
 void focusGained(java.awt.event.FocusEvent evt)
          for FocusListener interface Stop the monitor when component gains focus, so that the user can enter the new update value.
 void focusLost(java.awt.event.FocusEvent evt)
          for FocusListener interface Start the monitor and stop the timer thread.
 int getColorMode()
           
 java.lang.String getDeviceName()
          Return the device name to which this component is connected.
 java.lang.String getFormat()
          Return the text format (format is following the printf conventions)
 java.lang.String getPropertyName()
          Return the device property name to which this component is connected.
 boolean isFacusLock()
          Return focus lock
 void keyPressed(java.awt.event.KeyEvent e)
          for KeyListener interface
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
          for KeyListener interface Reset the timeout counter
 void run()
          Sleep a timeout period then remove the focus
 void setColorMode(int newColorMode)
          Set the color mode property
 void setDeviceName(java.lang.String newName)
          Set the Device name
 void setFocusLock(boolean b)
          Set focus lock action
 void setFormat(java.lang.String aFormat)
          Set the text format.
 void setPropertyName(java.lang.String newName)
          Set device property name
 void setText(java.lang.String s)
          Overwrite parent setText method to set the value in control system as well
 
Methods inherited from class java.awt.TextField
addActionListener, addNotify, echoCharIsSet, getColumns, getEchoChar, getMinimumSize, getMinimumSize, getPreferredSize, getPreferredSize, minimumSize, minimumSize, preferredSize, preferredSize, removeActionListener, setColumns, setEchoChar, setEchoCharacter
 
Methods inherited from class java.awt.TextComponent
addTextListener, getCaretPosition, getSelectedText, getSelectionEnd, getSelectionStart, getText, isEditable, removeNotify, removeTextListener, select, selectAll, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CTextField

public CTextField()
Null Constructor

CTextField

public CTextField(java.lang.String dName,
                  java.lang.String pName)
Null constructor with device name and property name
Parameters:
dName - device name
pName - property name
Method Detail

setColorMode

public void setColorMode(int newColorMode)
Set the color mode property
Parameters:
newColorMode - the new color mode, which may be one of:
  1. CConstants.CLRMOD_STATIC
  2. CConstants.CLRMOD_ALARM

getColorMode

public int getColorMode()

getFormat

public java.lang.String getFormat()
Return the text format (format is following the printf conventions)

setFormat

public void setFormat(java.lang.String aFormat)
Set the text format. The label will be forced to display the value of the specified device property.
Parameters:
format - the format of the label text, which following printf conventions. Or use one of following string:
  1. CConstants.FRMT_INTEGER
  2. CConstants.FRMT_FLOAT
  3. CConstants.FRMT_SCIENTIFIC
  4. CConstants.FRMT_AUTO
  5. CConstants.FRMT_HEX
  6. CConstants.FRMT_OCTAL

run

public void run()
Sleep a timeout period then remove the focus
Specified by:
run in interface java.lang.Runnable

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
for KeyListener interface Reset the timeout counter
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
for KeyListener interface
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

focusGained

public void focusGained(java.awt.event.FocusEvent evt)
for FocusListener interface Stop the monitor when component gains focus, so that the user can enter the new update value. At same time start a new timeout thread. If no value is entered () in 5 seconds, the focus is discarded and monitoring is resumed.
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent evt)
for FocusListener interface Start the monitor and stop the timer thread.
Specified by:
focusLost in interface java.awt.event.FocusListener

setFocusLock

public void setFocusLock(boolean b)
Set focus lock action
Parameters:
b - true (default) has focus lock timer on false no focus lock

isFacusLock

public boolean isFacusLock()
Return focus lock

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Send the new value to the control system and resume monitoring
Specified by:
actionPerformed in interface java.awt.event.ActionListener

setText

public void setText(java.lang.String s)
Overwrite parent setText method to set the value in control system as well
Overrides:
setText in class java.awt.TextField

setDeviceName

public void setDeviceName(java.lang.String newName)
Set the Device name
Specified by:
setDeviceName in interface CInterface
Parameters:
newName - the name of the device to monitor

getDeviceName

public java.lang.String getDeviceName()
Return the device name to which this component is connected. If device name is not set, return empty string "".
Specified by:
getDeviceName in interface CInterface

setPropertyName

public void setPropertyName(java.lang.String newName)
Set device property name
Specified by:
setPropertyName in interface CInterface
Parameters:
newName - the name of device property to monitor

getPropertyName

public java.lang.String getPropertyName()
Return the device property name to which this component is connected. If property name is not set, return empty string "".
Specified by:
getPropertyName in interface CInterface

deviceChanged

public void deviceChanged(DeviceEvent evt)
Specified by:
deviceChanged in interface DeviceListener