The control that is commonly used to enable a user to interactively influence the model. You can define a specific action (in the button's Action property) that will be performed every time the user clicks the button at the model runtime.

Simple demo model: Buttons Change Parameter Value

 To add a button

  1. Drag the  Button element from the  Controls palette into the graphical editor.
  2. Navigate to the button's properties.
  3. Type the text that you want to be displayed inside the button in the Label field. Optionally you can customize the text appearance (font, size, etc.) in the Appearance section.
  4. Type the Java code (that you want to be executed on clicking this button) in the Action section of the button's Properties. Make sure you terminate each line of the code with a semicolon.



Name – The name of the button. It is used to identify and access the control from code.

Ignore – If selected, the button will be excluded from the model.

Visible on upper level – If selected, the control will be also visible on the upper level where this agent lives.

Label – Here you can specify the text of the label displayed on the button.

Enabled – Here you can specify Boolean expression determining whether the button is enabled or disabled.


Here you can type the code to execute when the button is pressed.


Text color – The control specifies the color of the label's text. Click inside the control and choose a color from the set of the most used ones, or choose some custom color using the Colors dialog box.

Font – Specifies the font family for the label's text. You can adjust the size of the text in the field to the right (pt.).

Italic – If selected, the label's text will be italicized.

Bold – If selected, the label's text will be emphasized in bold.

Position and size

X – X-coordinate of the button's upper left corner.

Y – Y-coordinate of the button's upper left corner.

Width – The width of the button (in pixels).

Height – The height of the button (in pixels).


Visible – The control's visibility.  The control is visible when the specified expression evaluates to true, otherwise it is not visible.

Replication – Here you specify the number copies of this control you want to be created. If you leave this field empty, only one such control will be created.

Show name – If selected, the button's name will be displayed on the presentation diagram.

Icon – If selected, the button will be considered as a part of the agent's icon.


Enabling/disabling the button



boolean isEnabled()

Tests if the button is enabled or disabled. Returns true if enabled, otherwise false.

void setEnabled
(boolean yes)

Sets the control enabled or disabled.

yes - If true, the control will be enabled, if false - disabled. 

Executing the button's action programmatically



void action()

Executes the action associated with the button.

Label text



String getText()

Returns the button label text.

void setText(Object text)

Sets the button label text.

text - the new label text

Button position



double getX()

Returns the X coordinate of the control (namely, the X coordinate of its upper left corner).

double getY()

Returns the Y coordinate of the control (namely, the Y coordinate of its upper left corner).

void setX(double x)

Sets the X coordinate of the button.

x - the new value of X coordinate

void setY(double y)

Sets the Y coordinate of the button.

y - the new value of Y coordinate

void setPos(double x,
double y)

Sets new coordinates for the control.

x - the new value of x coordinate
y - the new value of y coordinate

Button size



double getWidth()

Returns the width of the button in pixels.

double getHeight()

Returns the height of the button in pixels.

void setWidth(double width)

Sets the width of the button equal to width.

void setHeight(double height)

Sets the height of the button equal to height.

Button visibility



boolean isVisible()

Returns the visibility of the button.

void setVisible(boolean v)

Sets the visibility of the button.


v - visibility: if true - the button is set to be visible, if false - not visible.

Related topics

 Aligning shapes

 API reference: ShapeButton class