Class FWSlider

All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, SwingConstants

public class FWSlider extends JSlider implements MouseListener, MouseMotionListener, ChangeListener
Wrapper class for JSlider to give all sliders a unified appearance. Among other things, FWSlider tries to place tick marks in a unified, intelligent manner and ensures that all sliders share the same minimum and preferred sizes.
Author:
Andreas Enders, Christoph Kunze
See Also:
  • Constructor Details

    • FWSlider

      public FWSlider(int aMin, int aMax)
      Constructs a new slider with a specific range of integers, that the user may choose from. Initially, the slider will be placed at the lower end.
      Parameters:
      aMin - Smallest selectable value
      aMax - Largest selectable value
    • FWSlider

      public FWSlider(double aMin, double aMax, double aValue, int aNumberOfLabels, int aPrecision, double aTickSpacing)
      Constructs a new slider for decimal values in a range and a specified preselected value. Internally the slider works on ticks (range / tick spacing, or 100000 ticks).
      Parameters:
      aMin - smallest selectable value
      aMax - largest selectable value
      aValue - preselected value (clamped to the range)
      aNumberOfLabels - number of labels
      aPrecision - number of decimal places shown (default 2)
      aTickSpacing - step between selectable values, or 0 for fine steps
    • FWSlider

      public FWSlider(int aMin, int aMax, int aValue, int aTickSpacing)
      Constructs a new slider with a specific range of integers, that the user may choose from and a specified preselected value (6 labels).
      Parameters:
      aMin - smallest selectable value
      aMax - largest selectable value
      aValue - preselected value
      aTickSpacing - step between selectable values
    • FWSlider

      public FWSlider(int aMin, int aMax, int aValue, int aTickSpacing, String aTickLabels, int aNumberOfTicks)
      Constructs a new slider with a specific range of integers, that the user may choose from and a specified preselected value. Label positions are chosen at round numbers, unless explicit labels are given.
      Parameters:
      aMin - smallest selectable value
      aMax - largest selectable value
      aValue - preselected value
      aTickSpacing - step between selectable values (minor tick spacing)
      aTickLabels - ;-separated label positions, or null for automatic labels
      aNumberOfTicks - approximate number of labels
  • Method Details

    • setToolTipEnabled

      public void setToolTipEnabled(boolean aEnabled)
      En/Disables the tooltip which may be shown during slider dragging (Default: TRUE).
      Parameters:
      aEnabled - true to show the tooltip
    • setEnabled

      public void setEnabled(boolean enabled)
      Enables or disables the slider; a decimal slider without range (min == max) stays disabled.
      Overrides:
      setEnabled in class JComponent
      Parameters:
      enabled - true to enable
    • isToolTipEnabled

      public boolean isToolTipEnabled()
      Returns whether a tooltip is shown during slider dragging (Default: TRUE).
      Returns:
      true if the tooltip is shown
    • getDoubleValue

      public double getDoubleValue()
      Returns:
      the decimal value of a decimal slider, rounded to the precision; 0 without range
    • setDoubleValue

      public void setDoubleValue(double aValue)
      Sets the value of a decimal slider (clamped to the range).
      Parameters:
      aValue - the value
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • stateChanged

      public void stateChanged(ChangeEvent e)
      Specified by:
      stateChanged in interface ChangeListener
    • toString

      public String toString()
      Overrides:
      toString in class Component