Example usage for javax.swing JSlider setMinorTickSpacing

List of usage examples for javax.swing JSlider setMinorTickSpacing

Introduction

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

Prototype

@BeanProperty(visualUpdate = true, description = "Sets the number of values between minor tick marks.")
public void setMinorTickSpacing(int n) 

Source Link

Document

This method sets the minor tick spacing.

Usage

From source file:Main.java

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

    slider.setMinorTickSpacing(2);
    slider.setMajorTickSpacing(10);/*ww  w.ja  va2  s  .co  m*/
    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);/*from www .ja va  2 s.com*/

    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);//from   w  w w.j  ava2  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 Main() {
    Container content = getContentPane();
    content.setBackground(Color.white);

    JSlider slider1 = new JSlider();
    slider1.setBorder(BorderFactory.createTitledBorder("JSlider without Tick Marks"));

    content.add(slider1, BorderLayout.NORTH);

    JSlider slider2 = new JSlider();
    slider2.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks"));

    slider2.setMajorTickSpacing(20);//from w  ww  .j  ava2s  .  co  m
    slider2.setMinorTickSpacing(5);
    slider2.setPaintTicks(true);
    content.add(slider2, BorderLayout.CENTER);

    JSlider slider3 = new JSlider();
    slider3.setBorder(BorderFactory.createTitledBorder("JSlider with Tick Marks & Labels"));

    slider3.setMajorTickSpacing(20);
    slider3.setMinorTickSpacing(5);
    slider3.setPaintTicks(true);
    slider3.setPaintLabels(true);
    content.add(slider3, BorderLayout.SOUTH);

    setSize(300, 300);
    setVisible(true);
}

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);//  www .j  av a 2s .c o m
    slider.setMajorTickSpacing(mjrTkSp);
    slider.setMinorTickSpacing(mnrTkSp);
    slider.setPaintLabels(true);
    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);//from w  w  w .j a v  a 2  s  .  c  o m
    slider.setMajorTickSpacing(majorTickSpacing);
    slider.setMinorTickSpacing(minorTickSpacing);
    slider.setPaintLabels(true);
    slider.addChangeListener(new SliderListener());
    panel.add(slider);
    return slider;
}

From source file:WeatherWizard.java

public void initComponents() {

    setLayout(new BorderLayout());

    JPanel p = new JPanel();
    p.add(new JLabel("Temperature:"));
    JSlider tempSlider = new JSlider(20, 100, 65);
    tempSlider.setMinorTickSpacing(5);
    tempSlider.setMajorTickSpacing(20);/*  w w w .j a v a2s.  co  m*/
    tempSlider.setPaintTicks(true);
    tempSlider.setPaintLabels(true);
    tempSlider.addChangeListener(this);
    p.add(tempSlider);
    add("North", p);

    painter = new WeatherPainter();
    painter.sun = loadImage("sun");
    painter.cloud = loadImage("cloud");
    painter.rain = loadImage("rain");
    painter.snow = loadImage("snow");
    painter.setTemperature(65);
    p.add("Center", painter);

}

From source file:ArcApp.java

public JSlider setSlider(int min, int max, int init, int mjrTkSp, int mnrTkSp) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, init);
    slider.setPaintTicks(true);/*from www .  j a va 2  s .c  o  m*/
    slider.setMajorTickSpacing(mjrTkSp);
    slider.setMinorTickSpacing(mnrTkSp);
    slider.setPaintLabels(true);
    slider.addChangeListener(new SliderListener());
    return slider;
}

From source file:AlphaCompositeDemo.java

public AlphaCompositeDemo() {
    super();/*from ww w. j av a2 s . c o  m*/
    Container container = getContentPane();

    canvas = new MyCanvas();
    container.add(canvas);

    rulesBox = new JComboBox(rulesLabels);
    rulesBox.setSelectedIndex(0);
    rulesBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    rulesBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox cb = (JComboBox) e.getSource();
            canvas.compositeRule = rules[cb.getSelectedIndex()];
            canvas.repaint();
        }
    });

    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(25);
    slider.setMinorTickSpacing(25);
    slider.setPaintLabels(true);
    slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider slider = (JSlider) e.getSource();
            canvas.alphaValue = (float) slider.getValue() / 100;
            canvas.repaint();
        }
    });

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 3));
    panel.add(rulesBox);
    panel.add(new JLabel("Alpha Adjustment x E-2: ", JLabel.RIGHT));
    panel.add(slider);
    container.add(panel, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    setSize(500, 300);
    setVisible(true);
}

From source file:House.java

public JSlider setSlider(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);//from  ww w  .ja  v a 2 s .c o m
    slider.setMajorTickSpacing(majorTickSpacing);
    slider.setMinorTickSpacing(minorTickSpacing);
    slider.setPaintLabels(true);
    slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider tempSlider = (JSlider) e.getSource();

            if (tempSlider.equals(sliderTransX)) {
                transX = sliderTransX.getValue() - 150.0;
                canvas.repaint();
            } else if (tempSlider.equals(sliderTransY)) {
                transY = sliderTransY.getValue() - 150.0;
                canvas.repaint();
            } else if (tempSlider.equals(sliderRotateTheta)) {
                rotateTheta = sliderRotateTheta.getValue() * Math.PI / 180;
                canvas.repaint();
            } else if (tempSlider.equals(sliderRotateX)) {
                rotateX = sliderRotateX.getValue();
                canvas.repaint();
            } else if (tempSlider.equals(sliderRotateY)) {
                rotateY = sliderRotateY.getValue();
                canvas.repaint();
            } else if (tempSlider.equals(sliderScaleX)) {
                if (sliderScaleX.getValue() != 0.0) {
                    scaleX = sliderScaleX.getValue() / 100.0;
                    canvas.repaint();
                }
            } else if (tempSlider.equals(sliderScaleY)) {
                if (sliderScaleY.getValue() != 0.0) {
                    scaleY = sliderScaleY.getValue() / 100.0;
                    canvas.repaint();
                }
            }
        }
    });
    panel.add(slider);

    return slider;
}