etomica.graphics
Class DeviceSelector

java.lang.Object
  extended by etomica.graphics.Device
      extended by etomica.graphics.DeviceSelector
All Implemented Interfaces:
GraphicalElement, Dimensioned

public class DeviceSelector
extends Device

Generic Device that has a combo box. Selecting an item from the combo box will invoke an action. Each item has its own action.


Nested Class Summary
 
Nested classes/interfaces inherited from class etomica.graphics.Device
Device.ActionSet
 
Field Summary
protected  HashMap<String,IAction> actionHash
           
 
Fields inherited from class etomica.graphics.Device
controller, unit
 
Constructor Summary
DeviceSelector(IController controller)
           
 
Method Summary
 void addOption(String actionText, IAction action)
           
 JLabel getLabel()
           
 JComboBox getSelector()
           
 Component graphic(Object obj)
          Returns the GUI element for display in the simulation.
 void removeOption(String actionText)
           
 void setLabel(String newLabel)
           
 void setSelected(int i)
          Sets the i-th item (counting from 0) in the list as the one currently selected.
 
Methods inherited from class etomica.graphics.Device
doAction, getController, getDimension, getPostAction, getPreAction, getUnit, graphic, setController, setPostAction, setPreAction, setUnit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actionHash

protected final HashMap<String,IAction> actionHash
Constructor Detail

DeviceSelector

public DeviceSelector(IController controller)
Method Detail

getSelector

public JComboBox getSelector()

getLabel

public JLabel getLabel()

setLabel

public void setLabel(String newLabel)

addOption

public void addOption(String actionText,
                      IAction action)

removeOption

public void removeOption(String actionText)

setSelected

public void setSelected(int i)
Sets the i-th item (counting from 0) in the list as the one currently selected. Argument outside bounds will result in an exception.


graphic

public Component graphic(Object obj)
Returns the GUI element for display in the simulation. Consists of a combo box used for the selector.

Specified by:
graphic in interface GraphicalElement
Specified by:
graphic in class Device
Parameters:
obj - An object that might be used to specify the graphic that the GraphicalElement is to return. In most cases the GraphicalElement ignores this parameter, and it can be set to null.
Returns:
A Component that can be used in the GUI of a graphical simulation
See Also:
Device, Display