Class ControlSwingElement

java.lang.Object
org.opensourcephysics.ejs.control.ControlElement
org.opensourcephysics.ejs.control.swing.ControlSwingElement
Direct Known Subclasses:
ControlBar, ControlButton, ControlCheckBox, ControlComboBox, ControlContainer, ControlDrawablesParent, ControlInputArea, ControlLabel, ControlNumberField, ControlRadioButton, ControlSlider, ControlTextArea, ControlTextField

public abstract class ControlSwingElement extends ControlElement
ControlSwingElement is a base class for an object that displays a visual java.awt.Component.

See Also:
  • Field Details

  • Constructor Details

    • ControlSwingElement

      public ControlSwingElement(Object _visual)
      Instantiates an object that wrapps a Swing JComponent of this type. If an object of an appropriate class is provided, it is used as the visual.
      Parameters:
      _visual - The javax.swing.JComponent to be wrapped
  • Method Details

    • createVisual

      protected abstract Component createVisual(Object _visual)
      Creates the visual component of this ControlElement, the one you can configure graphically. If an object of an appropriate class is provided, it is used as the visual.
      Parameters:
      _visual - The javax.swing.JComponent to be wrapped
    • getVisual

      public final Component getVisual()
      Returns the visual component of this ControlElement, the one you can configure graphically.
      Overrides:
      getVisual in class ControlElement
    • getComponent

      public Component getComponent()
      Returns the component of this ControlElement, the one that is added to a container.
      Overrides:
      getComponent in class ControlElement
    • getPropertyList

      public ArrayList<String> getPropertyList()
      Returns the list of all properties that can be set for this ControlElement. Subclasses that add properties should extend this table. Order is crucial here: Both for the presentation in an editor (f.i. ViewElement) and for the setValue() method.
      Specified by:
      getPropertyList in class ControlElement
    • getPropertyInfo

      public String getPropertyInfo(String _property)
      Returns information about a given property. Subclasses that add properties should extend this table.
    • The first keyword is ALWAYS the type.
    • The keyword CONSTANT applies to properties that can not be changed using the setValue() methods
    • The keyword BASIC is used by Ejs to group properties to the left hand side of the property editor
    • The keyword HIDDEN is used by Ejs so that it does not display an entry in the editor field
    • Specified by:
      getPropertyInfo in class ControlElement
    • parseConstant

      public Value parseConstant(String _propertyType, String _value)
      Checks if a value can be considered a valid constant value for a property If not, it returns null, meaning the value can be considered to be a GroupVariable or a primitive constant. This method implements more cases than really needed for the base class. This is in order to save repetitions in swing subclasses.
      Overrides:
      parseConstant in class ControlElement
      Parameters:
      String - _property The property name
      String - _value The proposed value for the property
    • setValue

      public void setValue(int _index, Value _value)
      Sets the value of the registered variables. Subclasses with internal values should extend this
      Overrides:
      setValue in class ControlElement
      Parameters:
      _index - A keyword index that distinguishes among variables
      _value - The object holding the value for the variable.
    • setDefaultValue

      public void setDefaultValue(int _index)
      Overrides:
      setDefaultValue in class ControlElement
    • getValue

      public Value getValue(int _index)
      Gets the value of any internal variable. Subclasses with internal values should extend this
      Overrides:
      getValue in class ControlElement
      Parameters:
      _index - A keyword index that distinguishes among variables
      Returns:
      Value _value The object holding the value for the variable.
    • getIcon

      protected ImageIcon getIcon(String _iconFile)