0
我知道所有其他類似的問題,但我似乎無法解決問題。我試過了「bar.repaint();」和「bar.update(bar.getGraphics());」但他們似乎都沒有工作。進度條不變
如果有人有時間快速查看它,我真的很感激它!這真的讓我感到困擾,我一直試圖解決它幾個小時。
它基本上是一個關機定時器。您輸入幾小時和幾秒鐘,然後倒計時直到它關閉計算機。它也有一個進度條,這是問題所在。它似乎並不想在每秒鐘後重新繪製。
這是很多代碼,所以我決定只上傳所有文件(2個文件)。
speedyshare.com/files/29072975/files.zip
提前感謝!
編輯:
的代碼片段,不工作:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
try{
if(varHours.getText() != null && varMins.getText() != null){
Thread countDownThread = new Thread(new Countdown(Integer.parseInt(varHours.getText()), Integer.parseInt(varMins.getText())));
int totalSecs = (Integer.parseInt(varHours.getText())*60*60) + (Integer.parseInt(varMins.getText())*60);
shutdownProgress = new javax.swing.JProgressBar(0, totalSecs);
countDownThread.start();
}else{
javax.swing.JOptionPane.showMessageDialog(null, "Please supply both fields!", "One or more fields were not supplied", javax.swing.JOptionPane.INFORMATION_MESSAGE);
}
}catch(Exception ex){
javax.swing.JOptionPane.showMessageDialog(null, "Error!\nCould not launch method countDown!", "Error!", javax.swing.JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_jButton1ActionPerformed
請在此發佈您的代碼的簡化部分,以便我們可以查看它,而無需轉到您發佈的鏈接。 – jjnguy
看看這個[CountDownProgressBar](http://stackoverflow.com/questions/5931933/how-to-make-timer-countdown-along-with-progress-bar/5932222#5932222)提示。這是一個不到40行代碼的完整示例。 –
查看我的更新。 :) – qwerty