etomica.graphics
Class DeviceButton

java.lang.Object
  extended by etomica.graphics.Device
      extended by etomica.graphics.DeviceButton
All Implemented Interfaces:
GraphicalElement, Dimensioned
Direct Known Subclasses:
DeviceControllerButton, DeviceToggleButton

public class DeviceButton
extends Device

Button that causes an action to be performed.


Nested Class Summary
 
Nested classes/interfaces inherited from class etomica.graphics.Device
Device.ActionSet
 
Field Summary
protected  JButton button
           
protected  IAction targetAction
           
 
Fields inherited from class etomica.graphics.Device
controller, unit
 
Constructor Summary
DeviceButton(IController controller)
          Constructs button that is not connected to any action.
DeviceButton(IController controller, IAction action)
          Constructs a button connected to the given action.
 
Method Summary
 IAction getAction()
          Returns the currently defined action associated with the button.
 JButton getButton()
           
static EtomicaInfo getEtomicaInfo()
           
 String getLabel()
           
 Component graphic(Object obj)
          Returns the GUI element for display in the simulation.
static void main(String[] args)
          Method to demonstrate and test the use of this class.
 void press()
          Performs the button's action.
 void setAction(IAction newAction)
          Defines the action to be performed when the button is pressed.
 void setLabel(String text)
          Sets the value of a descriptive label using the given string.
 
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

button

protected JButton button

targetAction

protected IAction targetAction
Constructor Detail

DeviceButton

public DeviceButton(IController controller)
Constructs button that is not connected to any action. Subsequent call to setAction is needed to make the button do something.

Parameters:
controller -

DeviceButton

public DeviceButton(IController controller,
                    IAction action)
Constructs a button connected to the given action. Controller and action may be changed independently after construction.

Method Detail

getButton

public JButton getButton()

getEtomicaInfo

public static EtomicaInfo getEtomicaInfo()

press

public void press()
Performs the button's action. Same effect as if the button were pressed in the user interface.


getAction

public IAction getAction()
Returns the currently defined action associated with the button.


setAction

public void setAction(IAction newAction)
Defines the action to be performed when the button is pressed.


graphic

public Component graphic(Object obj)
Returns the GUI element for display in the simulation.

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

setLabel

public void setLabel(String text)
Sets the value of a descriptive label using the given string.


getLabel

public String getLabel()
Returns:
the current instance of the descriptive label.

main

public static void main(String[] args)
Method to demonstrate and test the use of this class. Slider is used to control the temperature of a hard-sphere MD simulation