List of usage examples for javax.swing JSlider getMaximum
public int getMaximum()
BoundedRangeModel
. From source file:Main.java
public static void main(String[] argv) throws Exception { JSlider slider = new JSlider(); // Get the current value int value = slider.getValue(); // Get the minimum value int min = slider.getMinimum(); // Get the maximum value int max = slider.getMaximum(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JSlider slider = new JSlider(); Dictionary table = slider.getLabelTable(); ImageIcon icon = new ImageIcon("icon.gif"); JLabel label = new JLabel(icon); // Set at desired positions table.put(new Integer(slider.getMinimum()), label); table.put(new Integer(slider.getMaximum()), label); // Force the slider to use the new labels slider.setLabelTable(table);/*from ww w.ja v a2s .co m*/ }
From source file:Main.java
public static void setTickMarkers(JSlider slider) { final int min = slider.getMinimum(); final int max = slider.getMaximum(); final int delta = max - min; if (delta > 0) { final int sliderSize; if (slider.getOrientation() == SwingConstants.HORIZONTAL) sliderSize = slider.getPreferredSize().width; else// www. j ava2 s .c o m sliderSize = slider.getPreferredSize().height; // adjust ticks space on slider final int majTick = findBestMajTickSpace(sliderSize, delta); slider.setMinorTickSpacing(Math.max(1, majTick / 5)); slider.setMajorTickSpacing(majTick); slider.setLabelTable(slider.createStandardLabels(slider.getMajorTickSpacing(), majTick)); } }
From source file:se.llbit.chunky.renderer.ui.Adjuster.java
@Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); double value; if (logarithmic) { value = (double) (source.getValue() - source.getMinimum()) / (source.getMaximum() - source.getMinimum()); double logMin = FastMath.log10(min); double logMax = FastMath.log10(max); double scale = logMax - logMin; value = FastMath.pow(10, value * scale + logMin); } else {//w w w .jav a 2s . c o m double scale = (max - min) / (source.getMaximum() - source.getMinimum()); value = (source.getValue() - source.getMinimum()) * scale + min; } setTextField(value); valueChanged(value); }