com.xj.anylogic.engine.presentation
Class ShapeButton

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.presentation.ShapeControl
          extended by com.xj.anylogic.engine.presentation.ShapeButton
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class ShapeButton
extends ShapeControl
implements java.awt.event.ActionListener

Button control. Embeds a JButton component.

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.xj.anylogic.engine.presentation.ShapeControl
TYPE_DOUBLE, TYPE_INT, TYPE_STRING
 
Fields inherited from class com.xj.anylogic.engine.presentation.Shape
UNKNOWN_NAME
 
Constructor Summary
ShapeButton(Presentable p, boolean ispublic, int x, int y, int width, int height, java.awt.Color backgroundColor, java.awt.Color textColor, java.awt.Font font, java.lang.String text)
          Creates a persistent button control.
 
Method Summary
 void action()
          Executes the action associated with the button.
 void actionPerformed(java.awt.event.ActionEvent event)
          ActionListener implementation.
 javax.swing.JComponent getJComponent()
          Returns the embedded JButton.
 java.lang.String getText()
          Returns the button label text.
 void setText(java.lang.Object text)
          Sets the button label text
 void update()
          Updates the speific properties of a non-persistent button that are to be updated on each frame: text.
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeControl
clone, contains, draw, getHeight, getPresentable, getWidth, isEnabled, onClickAt, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth
 
Methods inherited from class com.xj.anylogic.engine.presentation.Shape
canHandleClick, getGroup, getName, getRotation, getScaleX, getScaleY, getX, getY, isVisible, onClick, setPos, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeButton

public ShapeButton(Presentable p,
                   boolean ispublic,
                   int x,
                   int y,
                   int width,
                   int height,
                   java.awt.Color backgroundColor,
                   java.awt.Color textColor,
                   java.awt.Font font,
                   java.lang.String text)
Creates a persistent button control. You should override the action() method.

Parameters:
p - the presentable object owning this control
ispublic - if true, the control is visible on container's presentation
x - the x coordinate
y - the y coordinate
width - the width
height - the height
backgroundColor - the background color.
textColor - the text color.
font - the text font
text - the text label of the button
Method Detail

action

public void action()
Executes the action associated with the button. This method must be overridden for persistent buttons.

Specified by:
action in class ShapeControl

getJComponent

public javax.swing.JComponent getJComponent()
Returns the embedded JButton.

Specified by:
getJComponent in class ShapeControl

setText

public void setText(java.lang.Object text)
Sets the button label text

Parameters:
text - the new label text

getText

public java.lang.String getText()
Returns the button label text.

Returns:
the button label text

update

public void update()
Updates the speific properties of a non-persistent button that are to be updated on each frame: text.

Overrides:
update in class ShapeControl

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
ActionListener implementation. Starts action execution.

Specified by:
actionPerformed in interface java.awt.event.ActionListener


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.