MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JSlider;

public class MainClass {
    public static void main(String args[]) {
        JFrame f = new JFrame("JSlider Sample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JSlider slider = new JSlider();
        slider.setMinorTickSpacing(5);
        slider.setMajorTickSpacing(10);
        slider.setPaintTicks(true);
        slider.setSnapToTicks(true);
        slider.setPaintTrack(false);
        slider.setPaintLabels(true);
        f.add(slider, BorderLayout.CENTER);
        f.setSize(300, 100);
        f.setVisible(true);
    }
}