com.xj.anylogic.engine.presentation
Class ShapeFileChooser

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

File chooser control. Embeds a JPanel with JTextField and JButton.
This object is only available in the AnyLogic Professional

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

Field Summary
static int TYPE_OPEN
           
static int TYPE_SAVE
           
 java.lang.String value
          Returns the currently selected file name (or empty string if no file selected) 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
ShapeFileChooser(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 title, int type, java.lang.String[][] fileNameFilters)
          Creates a persistent list box control.
 
Method Summary
 void action()
          Executes the action associated with a non-persistent list box.
 void actionPerformed(java.awt.event.ActionEvent e)
          ActionListener implementation.
 javax.swing.JComponent getJComponent()
          Returns the embedded JPanel which has JTextField and JButton inside
 java.lang.String getValue()
          Returns the currently selected file name or empty string if no file selected
 void setValue(java.lang.String fileName)
          Sets the selected filename to given fileName
Doesn't execute user action code
 void setValue(java.lang.String fileName, boolean callAction)
          Sets the selected filename to given fileName
Executes user action code (if any exists) if callAction parameter is true
 void setValueToDefault()
          Sets the selected filename of a non-persistent file chooser 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

TYPE_OPEN

public static final int TYPE_OPEN
See Also:
Constant Field Values

TYPE_SAVE

public static final int TYPE_SAVE
See Also:
Constant Field Values

value

public java.lang.String value
Returns the currently selected file name (or empty string if no file selected) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected file name from other places

Constructor Detail

ShapeFileChooser

public ShapeFileChooser(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 title,
                        int type,
                        java.lang.String[][] fileNameFilters)
Creates a persistent list box control. You should override the action() method, in which you can access the current selection of list box as "values".

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
title - the title of the file chooser dialog
type - one of
fileNameFilters - the array of pairs {Filter name, Extensions}, e.g.
 new String[][] { { "Text file", "*.txt" },
                { "Data source file", "*.mdb, *.xls" } }
 
Method Detail

action

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

Specified by:
action in class ShapeControl

getJComponent

public javax.swing.JComponent getJComponent()
Returns the embedded JPanel which has JTextField and JButton inside

Specified by:
getJComponent in class ShapeControl

setValueToDefault

public void setValueToDefault()
Sets the selected filename of a non-persistent file chooser 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 fileName)
Sets the selected filename to given fileName
Doesn't execute user action code

Parameters:
fileName - the file name

setValue

public void setValue(java.lang.String fileName,
                     boolean callAction)
Sets the selected filename to given fileName
Executes user action code (if any exists) if callAction parameter is true

Parameters:
fileName - the file name
callAction - if true user action code (if any exists) will be executed

getValue

public java.lang.String getValue()
Returns the currently selected file name or empty string if no file selected

Returns:
the currently selected file name or empty string if no file selected

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
ActionListener implementation. Opens file-chooser dialog.

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


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