This tutorial will teach you how to make the Percentage ProgressBar using Java.once the progress bar reached 100% it will show the Main Form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import java.util.logging.Level; import java.util.logging.Logger; public class pro extends javax.swing.JFrame { public pro() { initComponents(); } public static void main(String args[]) { pro sc = new pro(); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { sc .setVisible(true); } }); form1 s = new form1(); try { for(int i =0;i<=100;i++){ Thread.sleep(100); sc.bar.setValue(i); sc.txtpro.setText(Integer.toString(i)+"%"); if(i==100){ sc.setVisible(false); // inter.setVisible(true); sc.dispose(); } } } catch (InterruptedException ex) { Logger.getLogger(pro.class.getName()).log(Level.SEVERE, null, ex); } s.setVisible(true); sc.dispose(); } |