Class ButtonCtrl

java.lang.Object
  |
  +--java.awt.Component
        |
        +--ButtonCtrl
Direct Known Subclasses:
RectButton, RoundButton, SpacingButton

public abstract class ButtonCtrl
extends java.awt.Component

This super class is a generic button. It implements the general handling of a press button. Using parameters in the applet, it could load an image likes a .gif or .jpg, show a hint ( for now, it will show hint message into the status bar when the cursor pass over the button. Later, it will show the hint into tooltip window ) and some other parameters. All parameters are defined in Rosa applet parameters

Author:
Guy Parent
See Also:
Serialized Form

Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.lang.String kstrBorderParam
          Constant - Used to extract the border value parameters
protected  java.lang.String kstrHintParam
          Constant - Used to extract the hint string parameters
protected  java.lang.String kstrInputParam
          Constant - Used to extract the input string parameters
protected  java.lang.String kstrNameParam
          Constant - Used to extract the action name string parameters
protected static java.lang.String kstrPrefixParam
          Constant - First part of all button parameters.
protected  java.lang.String kstrValueParam
          Constant - Used to extract the action value string parameters
protected  java.lang.String kstrXYLocParam
          Constant - Used to extract the XY coordinate parameters
protected  Rosa2000 m_applet
          Use to set the status bar
protected  boolean m_bIsAutoPlace
          Use to know if the position for this button is take by the button manager.
protected  int m_borderColor
          Border color...
protected  boolean m_bPressed
          True if the button is pressed.
protected  java.awt.Image m_Img
          Default image.
protected  java.awt.event.ActionListener m_Listener
          Object listener the action.
protected  int m_nXSize
          Button Size including the offset.
protected  int m_nYSize
           
protected  java.lang.String m_strCmd
          Command that should be send on the pressed action
protected  java.lang.String m_strHint
          Help context.
protected  java.lang.String m_strName
          Button name.
protected  java.lang.String m_strNameParam
          Name of the form parameter to set when the button is pressed.
protected  java.lang.String m_strValueParam
          Specifies the value to set in the form parameter specified by the name
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
ButtonCtrl(java.lang.String strName, boolean bAutoPress, Rosa2000 applet)
          Constructors, Create an initialize the button.
ButtonCtrl(java.lang.String strName, int nXSize, int nYSize, boolean bAutoPress, Rosa2000 applet)
          Constructors Create an initialize the button.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
          Adds the specified action listener to receive action events from this button.
 java.lang.String getActionCommand()
          Get the action command string.
 java.lang.String getButtonActionName()
          Return the action name in the form parameter.
 java.lang.String getButtonActionValue()
          Return the action value attached to the action name in the form.
 java.lang.String getHint()
          Return the string to put in the tooltip.
 java.awt.event.ActionListener getListener()
          Return the active ActionListener
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of this component
static java.lang.String getPrefixButtonParam()
          Return string of the first part of all button parameters.
protected  void init()
          This method start the initialization.
 boolean isAutoPlacement()
          Get the current value in the m_bIsAutoPlace attributs.
 boolean isPressed()
          Return true if the button is in pressed state.
abstract  void paint(java.awt.Graphics g)
          This method is called to repaint the button.
protected  void readBorder()
          Read the border parameter.
protected  void readLocation()
          Read the location of the current button.
 void removeActionListener(java.awt.event.ActionListener l)
          Removes the specified action listener so that it no longer receives action events from this button.
 void setActionCommand(java.lang.String s)
          Set the command string.
 void setAutoPlacement(boolean bAuto)
          Set the current value in the m_bIsAutoPlace attributs.
 void setPressed(boolean bPressed)
          Set the button in the pressed state.
 void update(java.awt.Graphics g)
          Repaint the button.
 
Methods inherited from class java.awt.Component
, action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, postsOldMouseEvents, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, 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, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

kstrPrefixParam

protected static final java.lang.String kstrPrefixParam
Constant - First part of all button parameters.

kstrHintParam

protected final java.lang.String kstrHintParam
Constant - Used to extract the hint string parameters

kstrBorderParam

protected final java.lang.String kstrBorderParam
Constant - Used to extract the border value parameters

kstrXYLocParam

protected final java.lang.String kstrXYLocParam
Constant - Used to extract the XY coordinate parameters

kstrInputParam

protected final java.lang.String kstrInputParam
Constant - Used to extract the input string parameters

kstrNameParam

protected final java.lang.String kstrNameParam
Constant - Used to extract the action name string parameters

kstrValueParam

protected final java.lang.String kstrValueParam
Constant - Used to extract the action value string parameters

m_strName

protected java.lang.String m_strName
Button name. This string will be use to get all other parameter from the html page.

m_nXSize

protected int m_nXSize
Button Size including the offset.

m_nYSize

protected int m_nYSize

m_bPressed

protected boolean m_bPressed
True if the button is pressed.

m_Img

protected java.awt.Image m_Img
Default image. This image will be draw when the button still unpress. A "X" will be draw when the image in parameter will not able to load.

m_Listener

protected java.awt.event.ActionListener m_Listener
Object listener the action. This object manage the button action

m_strCmd

protected java.lang.String m_strCmd
Command that should be send on the pressed action

m_strHint

protected java.lang.String m_strHint
Help context. This string will be draw when the user pass over the button

m_borderColor

protected int m_borderColor
Border color... Not used yet

m_strNameParam

protected java.lang.String m_strNameParam
Name of the form parameter to set when the button is pressed.

m_strValueParam

protected java.lang.String m_strValueParam
Specifies the value to set in the form parameter specified by the name

m_applet

protected Rosa2000 m_applet
Use to set the status bar

m_bIsAutoPlace

protected boolean m_bIsAutoPlace
Use to know if the position for this button is take by the button manager.
Constructor Detail

ButtonCtrl

public ButtonCtrl(java.lang.String strName,
                  boolean bAutoPress,
                  Rosa2000 applet)
Constructors, Create an initialize the button. The button could be place in a specific location or in a toolbar. It set also the listener.
Parameters:
strName - Name of the button. This string will be use to extract all other associated parameters.
bAutoPress - If true, the button will be press up in the release button action. Otherwise, it will live press down until the applet call setPressed method.
applet - Applet where the current button is created. It will be used to set the status bar information likes tooltip.

ButtonCtrl

public ButtonCtrl(java.lang.String strName,
                  int nXSize,
                  int nYSize,
                  boolean bAutoPress,
                  Rosa2000 applet)
Constructors Create an initialize the button. The button could be place in a specific location or in a toolbar. It set also the listener.
Parameters:
strName - Name of the button. This string will be use to extract all other associated parameters.
nXSize - Width of the button.
nYSize - Height of the button.
bAutoPress - If true, the button will be press up in the release button action. Otherwise, it will live press down until the applet call setPressed method.
applet - Applet where the current button is created. It will be used to set the status bar information likes tooltip.
Method Detail

paint

public abstract void paint(java.awt.Graphics g)
This method is called to repaint the button. It must be override.
Overrides:
paint in class java.awt.Component

isAutoPlacement

public boolean isAutoPlacement()
Get the current value in the m_bIsAutoPlace attributs.
Returns:
boolean Return true if the button should be place automaticaly in the toolbar. This value is false when the parameter TB_BUT_?_XY is set.

setAutoPlacement

public void setAutoPlacement(boolean bAuto)
Set the current value in the m_bIsAutoPlace attributs.
Parameters:
bAuto - If true, the button will be place in the toolbar.

getButtonActionName

public java.lang.String getButtonActionName()
Return the action name in the form parameter. A value will be set in the submit operation.

getButtonActionValue

public java.lang.String getButtonActionValue()
Return the action value attached to the action name in the form.

getHint

public java.lang.String getHint()
Return the string to put in the tooltip. It will be draw when the user pass over the button.

getPrefixButtonParam

public static java.lang.String getPrefixButtonParam()
Return string of the first part of all button parameters.

setPressed

public void setPressed(boolean bPressed)
Set the button in the pressed state.

isPressed

public boolean isPressed()
Return true if the button is in pressed state.

getListener

public java.awt.event.ActionListener getListener()
Return the active ActionListener
See Also:
ActionListener

update

public void update(java.awt.Graphics g)
Repaint the button.
Overrides:
update in class java.awt.Component

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of this component
Overrides:
getPreferredSize in class java.awt.Component
Returns:
A dimension object indicating this component's preferred size.

setActionCommand

public void setActionCommand(java.lang.String s)
Set the command string. This command will be used when the action is perform.

getActionCommand

public java.lang.String getActionCommand()
Get the action command string.

addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Adds the specified action listener to receive action events from this button. Action events occur when a user presses or releases the mouse over this button.
Parameters:
l - The action listener.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Removes the specified action listener so that it no longer receives action events from this button. Action events occur when a user presses or releases the mouse over this button.
Parameters:
l - The action listener.

init

protected void init()
This method start the initialization. Read all associated parameters from the applet.

readBorder

protected void readBorder()
Read the border parameter. For now the current parameter is not used yet.

readLocation

protected void readLocation()
Read the location of the current button. If it found XY coordinate, the button will be draw at this place. Otherwise the attribut { @link #m_bIsAutoPlace m_bIsAutoPlace } will be set to true . Hence, the current button will be automaticaly place after the latest button insert in the toolbar.
See Also:
m_bIsAutoPlace, ToolbarPanel