***********************************************************************
COMPLETE SOURCE CODE FOR : AddJSliderIntoJFrame.java
***********************************************************************
import javax.swing.JSlider;
import javax.swing.JFrame;
import java.awt.FlowLayout;
public class AddJSliderIntoJFrame
{
public static void main(String[]args)
{
//Create a slider from JSlider class
JSlider slider=new JSlider();
//spacing between major tick
slider.setMajorTickSpacing(10);
//spacing between minor tick
slider.setMinorTickSpacing(1);
//make slider integer value visible
slider.setPaintLabels(true);
//make slider tick visible
slider.setPaintTicks(true);
//Create a JFrame with title ( Put slider into JFrame )
JFrame frame=new JFrame("Put slider into JFrame");
//set layout manager for JFrame
frame.setLayout(new FlowLayout());
//Add JSlider into JFrame
frame.add(slider);
//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set JFrame size
frame.setSize(400,100);
//Make JFrame visible. So we can see it.
frame.setVisible(true);
}
}
***********************************************************************
JUST COMPILE AND EXECUTE IT
***********************************************************************