How to Create a ProgressBar with a button in Java Netbeans.


Welcome To Java Tutorials Presented by Learning To Code

                                          Java Netbeans


First you need to implement ActionListener with your class-


public class progresso implements ActionListener{

     public void actionPerformed(ActionEvent evt){

              int n= progress.getValue(); // here progress= progressbar

              if(n<100){

                  n++;       // label means the text which get updated,(0%)

                   label.setText(Integer.toString(n)+"%");

             progress.setValue(n);

                  

              }

              else{

                  timer.stop();

              }

      }}

                 

 Now you need to write this code in the button action performed


        timer=new Timer(50,new your class name.progresso());

        timer.start();

   

Last You need to Declare the variable timer at variable declaration

private Timer timer;

 // Variables declaration - do not modify//

    private javax.swing.JProgressBar progress;

    // End of variables declaration//

        


   Hope It helps you.

   Help us reach 1k subs on youtube.

   Do Subscribe the Channel.



  


Comments

Popular posts from this blog

How to Create a Video Login page in Jframe In Java Netbeans

Airline Ticket Reservation System Project in Java Netbeans