A check box is a control element that can be selected or cleared. It displays its state to the user.
Check boxes are commonly used to modify the values of Boolean variables and parameters during model runtime.
If your variables are of the int type, we recommend modifying their values using sliders. For String and double variables, use edit boxes.
To add a check box
- Drag the
Check Box element from the
Controls palette into the graphical editor.
- Navigate to the properties of the element.
-
You can connect the check box to a Boolean variable or parameter. This way, when you change the value of the check box, the linked parameter or variable will immediately receive this value.
To link the control to a parameter, select the Link to check box and select the name of the parameter from the drop-down list. To learn more about linking controls to parameters, see Linking controls to parameters. - You can define an action to execute each time the value of the check box changes. Type the code you want to execute into the Action property. There, the current value of the check box is available as value, a Boolean variable: true if the check box is selected, and false otherwise.
- General
-
Name — The name of the check box. It is used to identify and access the control from code.
Show name — If selected, the name of the check box is displayed in the presentation diagram.
Lock — If selected, the check box is locked; it will not respond to any mouse actions during the model development time. To select it, click its icon in the elements view.
Ignore — If selected, the check box is excluded from the model.
Link to — Connect the check box to a Boolean variable or a parameter. This way, when you change the value of the check box, the linked parameter or variable will immediately receive this value.
Selected — [Visible unless Link to is selected] Determines whether the check box is selected or not by default. In the dynamic mode, requires an expression that returns a Boolean value. If this check box is linked to a variable or parameter, it uses the default value of this variable or parameter as its default value.
Action — The code to execute when the value of the check box is changed. The current value of the check box is available here as value, a local Boolean variable: true if the check box is selected, false otherwise.
- Appearance
-
Label — The text of the label displayed for the check box.
Enabled — Determines whether the check box is enabled or disabled. In the dynamic mode, requires an expression that returns a Boolean value.
Text color — The color of the label text. Click inside the control and select a color from the set of the most used ones or use the Colors dialog box to select a custom color.
Font — Specifies the font size for the label text.
Italic — If selected, the label text will be italicized.
Bold — If selected, the label text will be emphasized in bold.
- Position and size
-
Level — The level to which this control belongs.
X — The X-coordinate of the upper left corner of the control.
Y — The Y-coordinate of the upper left corner of the control.
Width — The width of the control (in pixels).
Height — The height of the control (in pixels).
- Visibility and presentation
-
Visible — The visibility of the control. Can be set to a dynamic expression that makes the control visible when evaluated to true.
Agent presentation — If selected, the control is included in the presentation of the agent. This means that if the agent hosting this control is embedded in another agent, the control will remain visible in that higher-level agent.
Agent icon — If selected, the control is considered as a part of the agent’s icon.
- Expert
-
Replication — The number of copies of this control that you want created. If this field is left empty, only one control will be created. This field can be set to a dynamic expression.
- Selecting and clearing
-
Function Description boolean isSelected() Returns the state of the check box.
Returns true if it is currently selected, false if not.void setSelected (boolean yes) Sets the state of the check box. Does not execute the user action code.
yes — if true, the check box is selected, if false, it is cleared.void setSelected(boolean yes, boolean callAction) Sets the selected state of the check box.
Executes the user action code (if there is any), if the callAction parameter is true.
yes — if true, the check box is selected, if false, it is cleared.
callAction — if true, the user action code (if there is any) will be executed.void setValueToDefault() Sets the state of the check box that was provided as the default one.
Does not execute the user action code. - Enabling and disabling
-
Function Description boolean isEnabled() Tests if the control is enabled or disabled. Returns true if enabled, false otherwise. void setEnabled(boolean yes) Toggles the control between enabled or disabled.
yes — If true, the control will be enabled, if false — disabled. - Executing the action
-
Function Description void action() Executes the action associated with the check box. - Label text
-
Function Description String getText() Returns the check box label text. void setText(Object text) Sets the check box label text.
text — the new label text. - Position
-
Function Description 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 check box.
x — the new value of X coordinate.void setY(double y) Sets the Y coordinate of the check box.
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. - Visibility
-
Function Description boolean isVisible() Returns the visibility of the control. void setVisible(boolean v) Sets the visibility of the control.
v — visibility: if true — the control is set to be visible, if false — not visible. - Group
-
Function Description ShapeGroup getGroup() Returns the group containing this control. - Level
-
Function Description Level getLevel() Returns the level on which this control is located.
-
How can we improve this article?
-