Example usage for javax.swing JSlider setFont

List of usage examples for javax.swing JSlider setFont

Introduction

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

Prototype

public void setFont(Font font) 

Source Link

Usage

From source file:Main.java

public static JSlider getSlider(int w, int h, String name, int minValue, int maxValue, int initValue) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, initValue);
    slider.setFont(getFont());
    slider.setPreferredSize(getSliderDimension(w, h));
    slider.setMinimumSize(getSliderDimension(w, h));
    slider.setName(name);//  w w  w.ja v  a 2  s  .c o  m
    return slider;
}

From source file:Main.java

public static JSlider getSlider(int w, int h, String name, int minValue, int maxValue) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, ((maxValue + minValue) / 2));
    slider.setFont(getFont());
    slider.setPreferredSize(getSliderDimension(w, h));
    slider.setMinimumSize(getSliderDimension(w, h));
    slider.setName(name);/*from  www.j  a  v  a2  s.c o m*/
    return slider;
}

From source file:components.SliderDemo.java

public SliderDemo() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    delay = 1000 / FPS_INIT;//from w w w .  ja  v a2s  .  c o  m

    //Create the label.
    JLabel sliderLabel = new JLabel("Frames Per Second", JLabel.CENTER);
    sliderLabel.setAlignmentX(Component.CENTER_ALIGNMENT);

    //Create the slider.
    JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL, FPS_MIN, FPS_MAX, FPS_INIT);

    framesPerSecond.addChangeListener(this);

    //Turn on labels at major tick marks.

    framesPerSecond.setMajorTickSpacing(10);
    framesPerSecond.setMinorTickSpacing(1);
    framesPerSecond.setPaintTicks(true);
    framesPerSecond.setPaintLabels(true);
    framesPerSecond.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    Font font = new Font("Serif", Font.ITALIC, 15);
    framesPerSecond.setFont(font);

    //Create the label that displays the animation.
    picture = new JLabel();
    picture.setHorizontalAlignment(JLabel.CENTER);
    picture.setAlignmentX(Component.CENTER_ALIGNMENT);
    picture.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(),
            BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    updatePicture(0); //display first frame

    //Put everything together.
    add(sliderLabel);
    add(framesPerSecond);
    add(picture);
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    //Set up a timer that calls this object's action handler.
    timer = new Timer(delay, this);
    timer.setInitialDelay(delay * 7); //We pause animation twice per cycle
                                      //by restarting the timer
    timer.setCoalesce(true);
}