Class TextFieldSlider

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener

public abstract class TextFieldSlider extends JPanel implements ChangeListener
See Also:
  • Constructor Details

    • TextFieldSlider

      public TextFieldSlider(int min, int max, int value, Font font, int minorTickSpacing, String[] labels, int sliderWidth, int textFieldWidth, String borderTitle)
      Create a TextFieldSlider
      Parameters:
      min - the minimum slider value
      max - the maximum slider value
      value - the initial slider value
      font - the font for the text field
      minorTickSpacing - the minor tick spacing (0 for none)
      labels - an array of labels to put on the slider (can be null)
      sliderWidth - the preferred width of the slider (0 for default)
      textFieldWidth - the preferred width of the text field (0 for default)
      borderTitle - the title for the border (null for no border)
  • Method Details

    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • stateChanged

      public void stateChanged(ChangeEvent arg0)
      Specified by:
      stateChanged in interface ChangeListener
    • sliderValueToRealValue

      public abstract double sliderValueToRealValue()
      Take the current slider value and convert in to the real value. This allows, for example, to have a slider range of 0 to 100 mapped to a real-valued range that is not even necessarily linear.
      Returns:
      the real value corresponding to the current slider value.
    • realValueToSliderValue

      public abstract int realValueToSliderValue(double val)
      Convert a real value to the corresponding slider value. This allows, for example, to have a slider range of 0 to 100 mapped to a real-valued range that is not even necessarily linear.
      Parameters:
      val - the real value to convert.
      Returns:
      the corresponding slider value. (The slider is not automatically set to this value)
    • valueString

      public abstract String valueString(double val)
      Convert format real value into a display string
      Parameters:
      val - the value to format
      Returns:
      the formatted value
    • valueChanged

      public abstract void valueChanged()
      This is called when the value changes, with by the slider or by entering text into the text field and hitting return (or leaving the field).
    • getSlider

      public JSlider getSlider()
      Get the slider component
      Returns:
      the slider component
    • getTextField

      public JTextField getTextField()
      Get the text field component
      Returns:
      the text field component
    • setValue

      public void setValue(int val)
      Convenience method to set the slider value
      Parameters:
      val - the value to set
    • getValue

      public int getValue()
      Convenience method to get the slider's current value.
      Returns:
      the slider's current value.
    • reset

      public void reset()
      Reset the slider back to its default value.