source file name: ProgressDemo.java

import javax.swing.*;    
  import java.awt.*;    
    import javax.swing.event.*;    
    public class ProgressDemo extends JFrame  implements ChangeListener
{    
    JProgressBar pb;    
    JSlider sd;
   public  ProgressDemo()
{

setLayout(null);       
    sd=new JSlider(0,1000);
pb=new JProgressBar(0,1000);  
sd.setBounds(50,50,500,100);
pb.setBounds(50,150,500,70);
    sd.setValue(10);    
sd.setMinorTickSpacing(20);
sd.setMajorTickSpacing(100);
sd.setPaintLabels(true);
    sd.setPaintTicks(true);    
    add(sd);  
    add(pb);
sd.addChangeListener(this);
           
    pb.setValue(0);    
    pb.setStringPainted(true);    
    
    }    
       public void stateChanged(ChangeEvent ce)
{
int n=sd.getValue();
pb.setValue(n);    
}
       
    public static void main(String[] args)
 {    
        ProgressDemo f=new ProgressDemo();  
f.setTitle("Slider and ProgressBar Program");
f.setSize(600,400);  
     f.setVisible(true);    
      
    }    
    }    

output: