Create slider using JSlider

Source code below will show you, how to create slider in java using JSlider class.

******************************************************************
COMPLETE SOURCE CODE FOR : CreateSliderUsingJSlider.java
******************************************************************


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

import java.awt.FlowLayout;

public class CreateSliderUsingJSlider
{
public static void main(String[]args)
{
//Create a slider using JSlider
JSlider slider=new JSlider();

//Create a window using JFrame with title ( Create slider using JSlider )
JFrame frame=new JFrame("Create slider using JSlider");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created slider into JFrame
frame.add(slider);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size to :
//WIDTH : 400 pixels
//HEIGHT : 200 pixels
frame.setSize(400,200);

//Make JFrame visible. So, we can see it.
frame.setVisible(true);
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************