Example usage for javax.swing JSlider setPaintTicks

List of usage examples for javax.swing JSlider setPaintTicks

Introduction

In this page you can find the example usage for javax.swing JSlider setPaintTicks.

Prototype

@BeanProperty(visualUpdate = true, description = "If true tick marks are painted on the slider.")
public void setPaintTicks(boolean b) 

Source Link

Document

Determines whether tick marks are painted on the slider.

Usage

From source file:Main.java

public static void setupSl(JSlider sl, int minorTickSpacing, int maximum) {
    sl.setMaximum(maximum);/*from  w  ww .j  a v a2 s  .c om*/
    sl.setMinorTickSpacing(minorTickSpacing);
    sl.setPaintLabels(true);
    sl.setPaintTicks(true);
    sl.setValue(0);
}

From source file:MessagePopup.java

public static JSlider getSlider(final JOptionPane optionPane) {
    JSlider slider = new JSlider();
    slider.setMajorTickSpacing(10);/*from  ww  w  .  j a v  a 2s. c o m*/
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            JSlider theSlider = (JSlider) changeEvent.getSource();
            if (!theSlider.getValueIsAdjusting()) {
                optionPane.setInputValue(new Integer(theSlider.getValue()));
            }
        }
    };
    slider.addChangeListener(changeListener);
    return slider;
}

From source file:Main.java

/**
 * Creates a JSlider built//  ww w .  j a  v a 2s .c o m
 * using a {@link DefaultBoundedRangeModel} and 
 * containing a {@link MouseWheelListener} 
 * and some usual default settings
 * 
 * @param model
 * @return the corresponding {@link JSlider}
 */
public static JSlider createJSlider(final BoundedRangeModel model) {
    final JSlider slider = new JSlider(model);
    slider.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            slider.setValue(-e.getWheelRotation() * model.getMaximum() / 100 + model.getValue());
        }
    });
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    //      slider.setMajorTickSpacing(model.getMaximum()/2);
    //      slider.setMinorTickSpacing(model.getMaximum()/10);
    //      slider.setSnapToTicks(true);
    return slider;
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25);

    slider.setMinorTickSpacing(2);//from ww w . j  av a 2 s  .  c  o m
    slider.setMajorTickSpacing(10);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    slider.setInverted(false);

    // We'll just use the standard numeric labels for now...
    slider.setLabelTable(slider.createStandardLabels(10));

    add(slider, BorderLayout.CENTER);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25);

    slider.setMinorTickSpacing(2);/*from w  w  w. j a v  a2  s  . c  o m*/
    slider.setMajorTickSpacing(10);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    slider.setOrientation(JSlider.VERTICAL);
    slider.setInverted(true);

    // We'll just use the standard numeric labels for now...
    slider.setLabelTable(slider.createStandardLabels(10));

    add(slider, BorderLayout.CENTER);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 50, 25);

    slider.setMinorTickSpacing(2);//from   ww w. j  a  v a  2 s . c o  m
    slider.setMajorTickSpacing(10);
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);

    slider.setOrientation(JSlider.VERTICAL);
    slider.setInverted(false);

    // We'll just use the standard numeric labels for now...
    slider.setLabelTable(slider.createStandardLabels(10));

    add(slider, BorderLayout.CENTER);
}

From source file:MainClass.java

public MainClass() {
    super(true);//  w w  w. j  a  va  2  s .  co m

    JSlider mySlider = new JSlider();
    mySlider.setMajorTickSpacing(20);
    mySlider.setMinorTickSpacing(10);
    mySlider.setPaintTicks(true);
    mySlider.setPaintLabels(true);

    CurvedBorder border = new CurvedBorder(10, Color.darkGray);
    mySlider.setBorder(border);

    add(mySlider);
}

From source file:CurvedExample.java

public CurvedExample() {
    super(true);/* ww w.  ja  v  a2 s. c o m*/

    JSlider mySlider = new JSlider();
    mySlider.setMajorTickSpacing(20);
    mySlider.setMinorTickSpacing(10);
    mySlider.setPaintTicks(true);
    mySlider.setPaintLabels(true);

    CurvedBorder border = new CurvedBorder(10, Color.darkGray);
    mySlider.setBorder(border);

    add(mySlider);
}

From source file:Main.java

public JSlider getSlider(int min, int max, int init, int mjrTkSp, int mnrTkSp) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, init);
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(mjrTkSp);
    slider.setMinorTickSpacing(mnrTkSp);
    slider.setPaintLabels(true);//from  w ww  . j  a v  a 2s.c  om
    slider.addChangeListener(new SliderListener());
    return slider;
}

From source file:SliderControlPaintLine.java

public JSlider createSlider(JPanel panel, int orientation, int minimumValue, int maximumValue, int initValue,
        int majorTickSpacing, int minorTickSpacing) {
    JSlider slider = new JSlider(orientation, minimumValue, maximumValue, initValue);
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(majorTickSpacing);
    slider.setMinorTickSpacing(minorTickSpacing);
    slider.setPaintLabels(true);/*from   w ww .j  a  v a 2  s  .c  om*/
    slider.addChangeListener(new SliderListener());
    panel.add(slider);
    return slider;
}