Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to to find the pixel position of the first tick mark on a jSlider scale?
    primarykey
    data
    text
    <p>I am trying to align a custom drawn graph to a jSlider's scale (the slider provides the X-axis scale for the graph). I need the slider knob to set values relating to the graph, so it really needs to be a jSlider. </p> <p>The trouble is, if the length of the scale labels change then the start position of the scale's first (and last) tick mark will be different, which requires me to manually change the position of the graph to match.</p> <p>Is it possible to set the slider's scale and then determine the pixel position of the first tick mark so I can set the start of the graph to match? </p> <p>trackRect.x of BasicSliderUI will give me the correct X point position but I am having trouble accessing it. I keep getting null pointers on trackRect with the following code; I am obviously missing something very basic here because I've seen a RangeSlider access trackRect.x by extending BasicSliderUI. I am simply not overriding anything like they are:</p> <p>Class to access the trackRect.x value:</p> <pre><code>import javax.swing.JSlider; import javax.swing.plaf.basic.BasicSliderUI; public class ExtendedBasicSliderUI extends BasicSliderUI { public ExtendedBasicSliderUI(JSlider b) { super(b); } public int getScaleStartPosition() { return trackRect.x; } </code></pre> <p>}</p> <p>in the constructor of the view which contains the slider:</p> <pre><code>initComponents(); extendedUI = new ExtendedBasicSliderUI(jSlider1); jSlider1.setUI(extendedUI); criteriaModel.setGraphAlignmentIntervalRatio(extendedUI.getScaleStartPosition()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload