com.xj.anylogic.engine.presentation
Class ShapeRadioButtonGroup

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.ShapeRadioButtonGroup
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 ShapeRadioButtonGroup
extends ShapeControl
implements java.awt.event.ActionListener

A group of radio buttons. Embeds JPanel containing a several grouped JRadioButtons. User's radio button group. Calls presentable object's executeControlAction( id, index, index of the selected button ) method when a button is selected (even if it was selected before). The orientation and the array of text labels for buttons can only be set once when the group is created.

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

Field Summary
 int value
          The currently selected radio button (-1 if none) that can be accessed in the overridden action() method.
 
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
ShapeRadioButtonGroup(Presentable p, boolean ispublic, int x, int y, int width, int height, java.awt.Color backgroundColor, java.awt.Color textColor, java.awt.Font font, boolean vertical, java.lang.String[] texts)
          Creates a persistent radio button group control.
 
Method Summary
 void action()
          Executes the action associated with a non-persistent radio button group.
 void actionPerformed(java.awt.event.ActionEvent event)
          ActionListener implementation.
 javax.swing.JComponent getJComponent()
          Returns the embedded JPanel.
 int getValue()
          Returns the currently selected radio button, -1 if none.
 void setValue(int index)
          Sets the radio button with the given index selected, makes others deselected.
 void setValue(int index, boolean callAction)
          Sets the radio button with the given index selected, makes others deselected.
 void setValueToDefault()
          Sets the value of a non-persistent radio button group to what was provided as the default one.
 
Methods inherited from class com.xj.anylogic.engine.presentation.ShapeControl
clone, contains, draw, getHeight, getPresentable, getWidth, isEnabled, onClickAt, restoreOwner, setEnabled, setHeight, setWidth, update
 
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
 

Field Detail

value

public int value
The currently selected radio button (-1 if none) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected radio button from other places.

Constructor Detail

ShapeRadioButtonGroup

public ShapeRadioButtonGroup(Presentable p,
                             boolean ispublic,
                             int x,
                             int y,
                             int width,
                             int height,
                             java.awt.Color backgroundColor,
                             java.awt.Color textColor,
                             java.awt.Font font,
                             boolean vertical,
                             java.lang.String[] texts)
Creates a persistent radio button group 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
vertical - sets the layout of the radio buttons
texts - the array of text labels of the radio buttons
Method Detail

action

public void action()
Executes the action associated with a non-persistent radio button group. This method must be overridden for persistent radio button groups.

Specified by:
action in class ShapeControl

getJComponent

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

Specified by:
getJComponent in class ShapeControl

setValueToDefault

public void setValueToDefault()
Sets the value of a non-persistent radio button group to what was provided as the default one.
Doesn't execute user action code

Overrides:
setValueToDefault in class ShapeControl

setValue

public void setValue(int index)
Sets the radio button with the given index selected, makes others deselected.
Doesn't execute user action code

Parameters:
index - the index of the button

setValue

public void setValue(int index,
                     boolean callAction)
Sets the radio button with the given index selected, makes others deselected.
Executes user action code (if any exists) if callAction parameter is true

Parameters:
index - the index of the button
callAction - if true user action code (if any exists) will be executed

getValue

public int getValue()
Returns the currently selected radio button, -1 if none.

Returns:
the currently selected radio button, -1 if none

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
ActionListener implementation. Listens to all radio buttons. Starts action execution.

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


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