JSlider class in java
//JSlider
import java.awt.*;
import javax.swing.*;
class JSlider_demo extends JFrame
{
Container con;
JSlider s1;
JSlider_demo()
{
con = getContentPane();
con.setLayout(new FlowLayout());
s1 = new JSlider();
s1.setValue(0);
s1.setMinorTickSpacing(2);
s1.setMajorTickSpacing(10);
s1.setPaintTicks(true);
s1.setPaintLabels(true);
con.add(s1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
JSlider_demo obj = new JSlider_demo();
obj.setSize(300, 100);
obj.setVisible(true);
}
}
OUTPUT:
Comments
Post a Comment