Class JSlider

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants, FieldReconciler.Reconcilable

public class JSlider extends JComponent implements SwingConstants, Accessible, FieldReconciler.Reconcilable
Emulator for JSlider, rendered by SJSlider (SD_sjslider).

Every getter answers from emulator-owned state and never reads the peer, so it works on any thread without a hop. Value, minimum, maximum and extent live in the BoundedRangeModel, which the emulator and the surrogate share: the emulator reads and writes the model as the JDK does, and the surrogate renders it from its own model listener. changeListener subscribes to the model directly, as the JDK's does, so a worker moving the model hears its ChangeEvent on the worker. The JDK's protected fields and the private flags are Swing-side fields per D_field_write_reconcile, pushed to the surrogate through withPeer. The surrogate keeps its own copies, because it renders and snaps from them. R_leaf_peer_lockdown-locked-down (JDK leaf — private peer ctor).

See Also:
  • Field Details

    • changeListener

      protected ChangeListener changeListener
      The listener createChangeListener() produced, subscribed to the model through modelRelay. Protected and named as the JDK's is, so a subclass that reads or replaces it compiles unchanged.
    • sliderModel

      protected BoundedRangeModel sliderModel
    • majorTickSpacing

      protected int majorTickSpacing
    • minorTickSpacing

      protected int minorTickSpacing
    • snapToTicks

      protected boolean snapToTicks
    • orientation

      protected int orientation
    • changeEvent

      protected transient ChangeEvent changeEvent
      Lazily created by fireStateChanged(), as in the JDK.
  • Constructor Details

    • JSlider

      public JSlider()
    • JSlider

      public JSlider(int orientation)
    • JSlider

      public JSlider(int min, int max)
    • JSlider

      public JSlider(int min, int max, int value)
    • JSlider

      public JSlider(int orientation, int min, int max, int value)
      Throws:
      IllegalArgumentException - if orientation is neither HORIZONTAL nor VERTICAL, or if min <= value <= max does not hold — the model's own check
    • JSlider

      public JSlider(BoundedRangeModel brm)
  • Method Details

    • reconcileFields

      public final void reconcileFields()
      D_field_write_reconcile repair hook — compares each JDK-shaped protected field against what was last pushed to the peer and re-pushes on mismatch, logging the ERROR. Final: the reconcile is framework plumbing, not a JDK hook a subclass should retarget.
      Specified by:
      reconcileFields in interface FieldReconciler.Reconcilable
    • getValue

      public int getValue()
    • setValue

      public void setValue(int n)
    • getMinimum

      public int getMinimum()
    • setMinimum

      public void setMinimum(int minimum)
    • getMaximum

      public int getMaximum()
    • setMaximum

      public void setMaximum(int maximum)
    • getExtent

      public int getExtent()
    • setExtent

      public void setExtent(int extent)
    • getValueIsAdjusting

      public boolean getValueIsAdjusting()
    • setValueIsAdjusting

      public void setValueIsAdjusting(boolean b)
    • getModel

      public BoundedRangeModel getModel()
    • setModel

      public void setModel(BoundedRangeModel newModel)
    • getOrientation

      public int getOrientation()
    • setOrientation

      public void setOrientation(int orientation)
    • getInverted

      public boolean getInverted()
    • setInverted

      public void setInverted(boolean b)
    • getPaintTicks

      public boolean getPaintTicks()
    • setPaintTicks

      public void setPaintTicks(boolean b)
    • getPaintTrack

      public boolean getPaintTrack()
    • setPaintTrack

      public void setPaintTrack(boolean b)
    • getPaintLabels

      public boolean getPaintLabels()
    • setPaintLabels

      public void setPaintLabels(boolean b)
    • getSnapToTicks

      public boolean getSnapToTicks()
    • setSnapToTicks

      public void setSnapToTicks(boolean b)
    • getMajorTickSpacing

      public int getMajorTickSpacing()
    • setMajorTickSpacing

      public void setMajorTickSpacing(int n)
    • getMinorTickSpacing

      public int getMinorTickSpacing()
    • setMinorTickSpacing

      public void setMinorTickSpacing(int n)
    • getLabelTable

      public Dictionary getLabelTable()
    • setLabelTable

      public void setLabelTable(Dictionary labels)
    • createStandardLabels

      public Hashtable<Integer, JComponent> createStandardLabels(int increment)
      Logs the rendering deferral WARN and returns an empty table, since tick labels do not render (SD_sjslider). An empty table satisfies the JDK's Hashtable<Integer, JComponent> value type trivially.
    • createStandardLabels

      public Hashtable<Integer, JComponent> createStandardLabels(int increment, int start)
      Two-argument form of createStandardLabels(int), with the same deferral.
    • updateLabelUIs

      protected void updateLabelUIs()
      JDK walks labelTable and calls updateUI on each JComponent value. Our labelTable is always empty (setLabelTable is deferred at the surrogate layer), so the walk has nothing to do.
    • addChangeListener

      public void addChangeListener(ChangeListener l)
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
    • fireStateChanged

      protected void fireStateChanged()
    • createChangeListener

      protected ChangeListener createChangeListener()
      JDK hook: the listener subscribed to the model, which re-fires as this slider.
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JComponent
    • getUIClassID

      public String getUIClassID()
      Overrides:
      getUIClassID in class JComponent
    • getUI

      public SliderUI getUI()
      Overrides:
      getUI in class JComponent
    • setUI

      public void setUI(SliderUI ui)
    • setFont

      public void setFont(Font f)
      Overrides:
      setFont in class JComponent
    • imageUpdate

      public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
      Specified by:
      imageUpdate in interface ImageObserver
      Overrides:
      imageUpdate in class Component
    • paramString

      protected String paramString()
      Overrides:
      paramString in class JComponent
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Component