com.xj.anylogic.engine.presentation
Class ShapeComboBox

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

Combo box control. Embeds a JComboBox component.

This object is only available in the AnyLogic Professional

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

Field Summary
 java.lang.String value
          The currently selected item of the combo box 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
ShapeComboBox(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[] items, boolean editable)
          Deprecated. use ShapeComboBox(Presentable, boolean, int, int, int, int, Color, Color, Font, String[], boolean, int)
ShapeComboBox(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[] items, boolean editable, int valueType)
          Creates a persistent combo box control.
 
Method Summary
 void action()
          Executes the action associated with a non-persistent combo box.
 void actionPerformed(java.awt.event.ActionEvent event)
          ActionListener implementation.
 double getDoubleValue()
          Returns the current double value of the combo box.
 int getIntValue()
          Returns the current int value of the combo box.
 java.lang.String[] getItems()
          Returns array of String items currently used in the combo box drop-down list
The returned array should not be changed by user
 javax.swing.JComponent getJComponent()
          Returns the embedded JComboBox.
 java.lang.String getValue()
          Returns the currently selected text item.
 void setItems(java.lang.String[] items)
          Sets new items for this combo box
This method preserves current combo box value: if it is editable if it is not-editable and current value is contained in new texts This method doesn't execute user action code (even if current selection changes)
This method throws an exception if this combo box has numeric value-type (ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT) and some item(s) can't be parsed as a number.
 void setItems(java.lang.String[] items, boolean callAction)
          Sets new items for this combo box
This method preserves current combo box value: if it is editable if it is not-editable and current value is contained in new texts
 void setValue(double value)
          Sets the numeric value of the combo box with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT.
 void setValue(double value, boolean callAction)
          Sets the numeric value of the combo box with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT.
 void setValue(java.lang.String text)
          Sets the selected text item of the combo box.
 void setValue(java.lang.String text, boolean callAction)
          Sets the selected text item of the combo box.
 void setValueToDefault()
          Sets the text of a non-persistent combo box 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 java.lang.String value
The currently selected item of the combo box that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected item from other places

Constructor Detail

ShapeComboBox

@Deprecated
public ShapeComboBox(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[] items,
                                boolean editable)
Deprecated. use ShapeComboBox(Presentable, boolean, int, int, int, int, Color, Color, Font, String[], boolean, int)


ShapeComboBox

public ShapeComboBox(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[] items,
                     boolean editable,
                     int valueType)
Creates a persistent combo box control. You should override the action() method, in which you can access the current selection of combo box as "value".

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
items - the array of text labels of the combo box
valueType - the type of the value edited in the combo box, supported types: ShapeControl.TYPE_STRING, ShapeControl.TYPE_DOUBLE, ShapeControl.TYPE_INT
Method Detail

action

public void action()
Executes the action associated with a non-persistent combo box. This method must be overridden for persistent combo boxes.

Specified by:
action in class ShapeControl

getJComponent

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

Specified by:
getJComponent in class ShapeControl

setValueToDefault

public void setValueToDefault()
Sets the text of a non-persistent combo box to what was provided as the default one.
Doesn't execute user action code

Overrides:
setValueToDefault in class ShapeControl

setValue

public void setValue(java.lang.String text)
Sets the selected text item of the combo box.
Doesn't execute user action code

Parameters:
text - the new selected text item

setValue

public void setValue(java.lang.String text,
                     boolean callAction)
Sets the selected text item of the combo box.
Executes user action code (if any exists) if callAction parameter is true.
If value-type is numeric and the given text isn't a valid number, nothing will be changed

Parameters:
text - the new selected text item
callAction - if true user action code (if any exists) will be executed

setValue

public void setValue(double value)
Sets the numeric value of the combo box with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT.
Doesn't execute user action code

Parameters:
value - the new value (double or int)

setValue

public void setValue(double value,
                     boolean callAction)
Sets the numeric value of the combo box with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT.
Executes user action code (if any exists) if callAction parameter is true

Parameters:
value - the new value (double or int)
callAction - if true user action code (if any exists) will be executed

getValue

public java.lang.String getValue()
Returns the currently selected text item.

Returns:
the currently selected text item

getIntValue

public int getIntValue()
Returns the current int value of the combo box.
Method throws an exception when the value isn't a number.

Returns:
the current int value of the combo box

getDoubleValue

public double getDoubleValue()
Returns the current double value of the combo box.
Method throws an exception when the value isn't a number.

Returns:
the current double value of the combo box

getItems

public java.lang.String[] getItems()
Returns array of String items currently used in the combo box drop-down list
The returned array should not be changed by user

Returns:
array of String items currently used in the combo box drop-down list

setItems

public void setItems(java.lang.String[] items)
Sets new items for this combo box
This method preserves current combo box value: This method doesn't execute user action code (even if current selection changes)
This method throws an exception if this combo box has numeric value-type (ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT) and some item(s) can't be parsed as a number.

Parameters:
items - the array of String items to be placed in the combo box drop-down list

setItems

public void setItems(java.lang.String[] items,
                     boolean callAction)
Sets new items for this combo box
This method preserves current combo box value:

Parameters:
items - the array of String items to be placed in the combo box drop-down list
callAction - if true and selection changes, user action code (if any exists) will be executed

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.