adm
Class CToggleButton

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--adm.CCanvas
                    |
                    +--adm.CToggleButton

public class CToggleButton
extends CCanvas
implements java.awt.event.MouseListener

CToggleButton implements a toggle button widget with 2 mutually exclusive buttons. This widget must be connected to a property of binary Enum type. The Enum strings will be the labels on the button. These two mutually exclusive buttons are represented by a raised and a etched rectangle. The etched button use to indicate the current state. Only the raised button works like a real push button. When the button is pressed the set action is sent to control system and the waiting cursor will appear. If the operation succeeds, the raised button will change to etched and etched button becomes raised. The cursor will revert to the default cursor.

If the connected device/property is not of type of binary Enum, the "not" and "binary" strings will be the label of the buttons. No action perform when the either button is pressed.

The toggle button can be stacked by ROW or by COLUMN using setStacking(int) method. The default stacking is COLUMN.

Since:
adm0.2
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CToggleButton()
          Null constructor.
CToggleButton(java.lang.String dName, java.lang.String pName)
          Null constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent event)
          Get the Enum value from control system and add to the choice at first call.
 byte getStacking()
          Get the stacking position
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
          Handle the mouse press.
 void mouseReleased(java.awt.event.MouseEvent me)
          To send the new value to the control system.
 void paint(java.awt.Graphics g)
          Draw two buttons and labels
 void setStacking(byte newStacking)
          Set the stacking position
 
Methods inherited from class adm.CCanvas
getDeviceName, getPropertyName, setDeviceAndPropertyName, setDeviceName, setPropertyName
 
Methods inherited from class java.awt.Canvas
addNotify
 
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, getMinimumSize, getName, getParent, getPeer, getPreferredSize, 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, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, 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

CToggleButton

public CToggleButton()
Null constructor.

CToggleButton

public CToggleButton(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

setStacking

public void setStacking(byte newStacking)
Set the stacking position
Parameters:
newStacking - new stacking position, which may be one of:
  1. CConstants.COLUMN (default)
  2. CConstants.ROW

getStacking

public byte getStacking()
Get the stacking position

paint

public void paint(java.awt.Graphics g)
Draw two buttons and labels
Overrides:
paint in class java.awt.Canvas

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Handle the mouse press. Set the evnetLock to true only when the up-button is pressed.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
To send the new value to the control system. The cursor change to waiting cursor. The setListener will keep track the error message return from the control system and set the cursor back to default cursor.
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

deviceChanged

public void deviceChanged(DeviceEvent event)
Get the Enum value from control system and add to the choice at first call. Change the select item to the current Enum when the control system updates.