Class TitledSpinner

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

public class TitledSpinner extends JPanel implements ChangeListener
JSpinner with titled border
See Also:
  • Field Details

  • Constructor Details

    • TitledSpinner

      public TitledSpinner(String title, int index, UpdateNV update)
      Construct a new titledSpinner
      Parameters:
      title - to be displayed
      index - of the associated NV
      update - callback funtion to apply new value
  • Method Details

    • init

      public void init(double init, double min, double max, double step)
      Initialise with float values
      Parameters:
      init - Initial value
      min - Minimum value
      max - Maximum value
      step - Step
    • init

      public void init(int init, int min, int max, int step)
      Initialise with int values
      Parameters:
      init - Initial value for spinner
      min - Minimum value for spinner
      max - Maximum value fro spinner
      step - Step size for spinner adjustments
    • setToolTip

      public void setToolTip(String tt)
      Set the tool tip
      Parameters:
      tt - tooltip text
    • setEnabled

      public void setEnabled(boolean b)
      Enable the spinner
      Overrides:
      setEnabled in class JComponent
      Parameters:
      b - boolean to enable (true) or disable (false)
    • isEnabled

      public boolean isEnabled()
      Is the spinner enabled
      Overrides:
      isEnabled in class Component
      Returns:
      true or false
    • setValue

      public void setValue(Number val)
      Set the current spinner value Check that the supplied value is the correct type for the current spinner, otherwise we seem to get more stateChange events that can update the gui that change the spinner again, ... leading to an endless code loop
      Parameters:
      val - Number which should contain a Double or an Integer
    • getDoubleValue

      Get the Double representation of the spinner value
      Returns:
      Spinner value as Double
    • getIntegerValue

      public int getIntegerValue()
      Get the int representation of the spinner value
      Returns:
      Spinner values as int
    • stateChanged

      public void stateChanged(ChangeEvent e)
      Call back with updated value
      Specified by:
      stateChanged in interface ChangeListener
      Parameters:
      e - the spinner change event
    • getPreferredSize

      The preferred width on the panel must consider the width of the text used on the TitledBorder from
      Overrides:
      getPreferredSize in class JComponent