thieumao

Phần Loading trong Java (JProgressBar)

Oct 12th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1.     private void btClickActionPerformed(java.awt.event.ActionEvent evt) {                                        
  2.         // TODO add your handling code here:
  3.         tt.start();
  4.     }                                      
  5.     Thread tt = new Thread() {
  6.         public void run() {
  7.             tfRun.setText("Không được mà");
  8.             for (int i = 1; i <= 10; i++) {
  9.                 tfRun.setText(String.valueOf(i));
  10.                 pbLoading.setValue(i * 10);
  11.                 System.out.println(" " + i);
  12.                 try {
  13.                     Thread.sleep(1000);
  14.                 } catch (InterruptedException ex) {
  15.                     Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
  16.                 }
  17.                 System.out.println("");//ok, van de la tai GUi bi dung'
  18.             }
  19.         }
  20.     };
Advertisement
Add Comment
Please, Sign In to add comment