Practical 9 java

 avatar
Rohit143
java
2 years ago
1.1 kB
3
Indexable
Never

 import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.*;
 class MyJFrame extends JFrame{
     JProgressBar progressBar;

     MyJFrame(){
         progressBar =new JProgressBar();
         progressBar.setValue(0);
         progressBar.setStringPainted(true);
         progressBar.setBackground(Color.green);
         progressBar.setBounds(100, 100, 100, 20);

         
         setLayout(new FlowLayout());
         add(progressBar);


         setVisible(true);
         setSize(400,500);
         setDefaultCloseOperation(3);


         fill();



     }
     public void fill(){
         int i= 0;
         try{
             while (i<101) {
                 progressBar.setValue(i);
                 Thread.sleep(1000);
                 i+=20;
                 
             }
             }
        catch(Exception e){
            System.out.println(e);
        }
     }
 }

public class practical9 {

    public static void main(String[] args) {
        new MyJFrame();
    }
}