Saturday, 6 February 2016

How to make JSlider in java

To make JSlider

Program

import javax.swing.*;
import java.awt.*;

public class JSlider_demo
{
   public static void main(String[] args)
   {
 
       JFrame f = new JFrame("welcome");

  JSlider s = new JSlider(JSlider.HORIZONTAL,2,6,3);

  s.setPaintLabels(true);
  s.setPaintTicks(true);
  s.setPaintTrack(true);

  f.add(s);
  f.setLayout(new FlowLayout(FlowLayout.LEFT));

  f.setSize(400,400);
  f.setVisible(true);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

output


No comments:

Post a Comment