Package com.anylogic.engine.presentation
- Nested Class Summary
- Nested classes/interfaces inherited from class com.anylogic.engine.presentation.ShapeControl
- Field Summary
- Constructor Summary
- Method Summary
- Methods inherited from class com.anylogic.engine.presentation.ShapeInputControl
- Methods inherited from class com.anylogic.engine.presentation.ShapeControl
- Methods inherited from class com.anylogic.engine.presentation.Shape
- Methods inherited from class java.lang.Object
- Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement
- Field Details
- Constructor Details
- Method Details
- java.lang.Object
- com.anylogic.engine.presentation.Shape
- com.anylogic.engine.presentation.ShapeControl
- com.anylogic.engine.presentation.ShapeInputControl
- com.anylogic.engine.presentation.ShapeTextField
- All Implemented Interfaces:
com.anylogic.engine.internal.Child
,Locatable2D
,AggregatableAnimationElement
,HasLevel
,LevelElement
,SVGElement
,Serializable
,Cloneable
public class ShapeTextField extends ShapeInputControl
TextField control. Embeds JTextField.
User's text field. Calls presentable object's executeControlAction( id, index, text );
method on focus lost or Enter pressed.
- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
Modifier and Type | Field | Description |
---|---|---|
String | value |
The current text in the text field that can be accessed
in the overridden action() method.
Use getText() to obtain the current text from
other places. |
Constructor | Description |
---|---|
ShapeTextField |
Creates a persistent text field control.
|
ShapeTextField |
Creates a persistent text field control.
|
ShapeTextField |
Deprecated.
may be removed in future releases
|
ShapeTextField |
Deprecated.
may be removed in future releases
|
Modifier and Type | Method | Description |
---|---|---|
void | executeUserAction |
This method is internal and shouldn't be called by user.
it may be removed/renamed in future. |
double | getDoubleValue() |
Returns the current
double value of the text field.Method throws an exception when the value isn't a number. |
int | getIntValue() |
Returns the current
int value of the text field.Method throws an exception when the value isn't a number. |
double | getMax() |
Returns the maximum value of the text field.
This method may only be used in text fields with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT |
double | getMin() |
Returns the minimum value of the text field.
This method may only be used in text fields with value type ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT |
String | getText() |
Returns the text of the text field.
|
void | setBackgroundColor |
Sets the background color of this text field.
|
void | setRange |
Sets the minimum and maximum values of the text field with numeric value-type:
ShapeControl.TYPE_DOUBLE , ShapeControl.TYPE_INT .Doesn't execute user action code Leaving both min and max with zeroes will result in unlimited range. If text field is configured to work with int values (see ShapeControl.TYPE_INT ),
the given [min, max] range may be automatically corrected to have
integer bounds (within the given double bounds)This method does nothing if the text field already has such range |
void | setRange |
Sets the minimum and maximum values of the text field with numeric value-type:
ShapeControl.TYPE_DOUBLE , ShapeControl.TYPE_INT .If current text field value changes, executes user action code (if any exists) in the same thread - if callAction parameter is true Leaving both min and max with zeroes will result in unlimited range. If text field is configured to work with int values (see ShapeControl.TYPE_INT ),
the given [min, max] range may be automatically corrected to have
integer bounds (within the given double bounds)This method does nothing if the text field already has such range |
void | setText |
Sets the numeric value of the text field with value type
ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT .Doesn't execute user action code |
void | setText |
Sets the numeric value of the text field with value type
ShapeControl.TYPE_DOUBLE or ShapeControl.TYPE_INT .Executes user action code (if any exists) if callAction
parameter is true |
void | setText |
Sets the text of the text field
Doesn't execute user action code If value-type is numeric and the given text isn't
a valid number, nothing will be changed, and if text is
a number but not within [min, max] , it will be
corrected to min or max |
void | setText |
Sets the text of the text field
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, and if text is
a number but not within [min, max] , it will be
corrected to min or max |
void | setTextColor |
Sets the text color of this text field.
|
action, clone, contains, executeAction, getHeight, getPresentable, getWidth, isEnabled, randomPointInside, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth
canHandleClick, findSVGElement, getDrawMode, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, removeSVGFromOwner, removeSVGImage, resetSVGState, setLevel, setPos, setPos, setPublic_xjal, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties
@AnyLogicInternalAPI public String value
The current text in the text field that can be accessed
in the overridden action() method.
Use
Use
getText()
to obtain the current text from
other places.@Deprecated public ShapeTextField(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, Color textColor, Font font)
Deprecated.
may be removed in future releases
public ShapeTextField(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, Color textColor, boolean enabled, Font font)
Creates a persistent text field control. You should override the action()
method.
Created text box has value-type
Created text box has value-type
ShapeControl.TYPE_STRING
- Parameters:
p
- the presentable object owning this controlispublic
- iftrue
, the control is visible on container's presentationx
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightbackgroundColor
- the background colortextColor
- the text colorenabled
- the initial enabled statefont
- the text font
@Deprecated public ShapeTextField(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, Color textColor, Font font, ShapeControl.ValueType valueType, double min, double max)
Deprecated.
may be removed in future releases
public ShapeTextField(Presentable p, boolean ispublic, double x, double y, double width, double height, Color backgroundColor, Color textColor, boolean enabled, Font font, ShapeControl.ValueType valueType, double min, double max)
Creates a persistent text field control. You should override the action()
method.
- Parameters:
p
- the presentable object owning this controlispublic
- iftrue
, the control is visible on container's presentationx
- the x coordinatey
- the y coordinatewidth
- the widthheight
- the heightbackgroundColor
- the background colortextColor
- the text colorenabled
- the initial enabled statefont
- the text fontvalueType
- the type of the value edited in the text field, supported types:ShapeControl.TYPE_STRING
,ShapeControl.TYPE_DOUBLE
,ShapeControl.TYPE_INT
min
- the minimum value of the text field with numeric value-type:ShapeControl.TYPE_DOUBLE
,ShapeControl.TYPE_INT
Ignored if value-type isShapeControl.TYPE_STRING
max
- the maximum value of the text field with numeric value-type:ShapeControl.TYPE_DOUBLE
,ShapeControl.TYPE_INT
Ignored if value-type isShapeControl.TYPE_STRING
public void setBackgroundColor(Color backgroundColor)
Sets the background color of this text field.
- Parameters:
backgroundColor
- the desired backgroundColor
public void setTextColor(Color textColor)
Sets the text color of this text field.
- Parameters:
textColor
- the desired textColor
public void setText(String text)
Sets the text of the text field
Doesn't execute user action code
If value-type is numeric and the given
Doesn't execute user action code
If value-type is numeric and the given
text
isn't
a valid number, nothing will be changed, and if text
is
a number but not within [min, max]
, it will be
corrected to min
or max
- Parameters:
text
- the new text
public void setText(String text, boolean callAction)
Sets the text of the text field
Executes user action code (if any exists) if
If value-type is numeric and the given
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, and if text
is
a number but not within [min, max]
, it will be
corrected to min
or max
- Parameters:
text
- the new textcallAction
- iftrue
user action code (if any exists) will be executed
public void setText(double value)
Sets the numeric value of the text field with value type
Doesn't execute user action code
ShapeControl.TYPE_DOUBLE
or ShapeControl.TYPE_INT
.Doesn't execute user action code
- Parameters:
value
- the new value (double
orint
)
public void setText(double value, boolean callAction)
Sets the numeric value of the text field with value type
Executes user action code (if any exists) if
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
orint
)callAction
- iftrue
user action code (if any exists) will be executed
public String getText()
Returns the text of the text field.
- Returns:
- the text of the text field
public int getIntValue()
Returns the current
Method throws an exception when the value isn't a number.
int
value of the text field.Method throws an exception when the value isn't a number.
- Returns:
- the current
int
value of the text field
public double getDoubleValue()
Returns the current
Method throws an exception when the value isn't a number.
double
value of the text field.Method throws an exception when the value isn't a number.
- Returns:
- the current
double
value of the text field
public void setRange(double min, double max)
Sets the minimum and maximum values of the text field with numeric value-type:
Doesn't execute user action code
Leaving both min and max with zeroes will result in unlimited range.
If text field is configured to work with int values (see
This method does nothing if the text field already has such range
ShapeControl.TYPE_DOUBLE
, ShapeControl.TYPE_INT
.Doesn't execute user action code
Leaving both min and max with zeroes will result in unlimited range.
If text field is configured to work with int values (see
ShapeControl.TYPE_INT
),
the given [min, max]
range may be automatically corrected to have
integer bounds (within the given double bounds)This method does nothing if the text field already has such range
- Parameters:
min
- the new minimum valuemax
- the new maximum value
public void setRange(double min, double max, boolean callAction)
Sets the minimum and maximum values of the text field with numeric value-type:
If current text field value changes, executes user action code (if any exists) in the same thread - if
Leaving both min and max with zeroes will result in unlimited range.
If text field is configured to work with int values (see
This method does nothing if the text field already has such range
ShapeControl.TYPE_DOUBLE
, ShapeControl.TYPE_INT
.If current text field value changes, executes user action code (if any exists) in the same thread - if
callAction
parameter is true
Leaving both min and max with zeroes will result in unlimited range.
If text field is configured to work with int values (see
ShapeControl.TYPE_INT
),
the given [min, max]
range may be automatically corrected to have
integer bounds (within the given double bounds)This method does nothing if the text field already has such range
- Parameters:
min
- the new minimum value, leaving both min and max with zeroes will result in unlimited rangemax
- the new maximum value, leaving both min and max with zeroes will result in unlimited rangecallAction
- iftrue
user action code (if any exists) will be executed if current text field value changes
public double getMin()
Returns the minimum value of the text field.
This method may only be used in text fields with value type
This method may only be used in text fields with value type
ShapeControl.TYPE_DOUBLE
or ShapeControl.TYPE_INT
- Returns:
- the minimum value of the text field
public double getMax()
Returns the maximum value of the text field.
This method may only be used in text fields with value type
This method may only be used in text fields with value type
ShapeControl.TYPE_DOUBLE
or ShapeControl.TYPE_INT
- Returns:
- the maximum value of the text field
@AnyLogicInternalAPI public void executeUserAction(String value)
Description copied from interface:
SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
it may be removed/renamed in future.
- Specified by:
executeUserAction
in interfaceSVGElement
- Overrides:
executeUserAction
in classShape