매초마다 라벨을 업데이트하는 자바 스윙 타이머가 있습니다. 타이머를 시작하면 매 초마다 레이블이 업데이트되고 모든 것이 잘 작동합니다.자바 타이머가 임의의 시간 후에 트리거되지 않음
그런 다음 실행에서 실행으로 변경되는 임의의 시간 간격 후에 레이블의 업데이트가 중지됩니다. 타이머 업데이트 코드에 중단 점을 넣었으므로 더 이상 트리거되지 않습니다.
나는 또한 정상적으로 타이머를 멈추게 할 모든 장소에 로그 문을 넣었지만 그 장소는 아무 것도 호출되지 않았다.
무엇이 문제 일 수 있습니까?
편집 : 여기에 코드
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent arg0) {
secondsRemaining--;
System.out.println("Seconds remaining:" + secondsRemaining);
//update the progressbar
double initialLength = currentSettings.getLength()*60;
double progress = (initialLength - secondsRemaining)/initialLength ;
progressBarTime.setProgress(progress);
//update the progress label
progressPercentage.setText(((int)(progress * 100)) + "%");
if (secondsRemaining >= 0) {
updateTimeRemaining(secondsToString(secondsRemaining));
} else {
System.out.println(">0 seconds TIMER STOPPED with the number of seconds = " + secondsRemaining);
treatmentTimer.stop();
// set the status to Finished
currentState = State.FINISHED;
}
}
}
그리고 타이머 초기화의 예입니다
tTimer = new Timer(1000, actionListener);
tTimer.start();
어떤 이상한 것은 프로그램이 즉, 설치된 JRE 7u7와 PC에 잘 작동한다는 것입니다 타이머가 라벨을 성공적으로 업데이트하지만, 7u10을 사용하는 두 대의 PC에서 시도했지만이 타이머 중지 문제는 두 가지 모두에서 발생합니다.
어디에서나 예외가 발생합니까? (로그 파일, 시스템 출력/오류 등)? 타이머 스레드가 캐치되지 않는 예외에 의해 죽을 가능성이 있습니다 – radai
코드를 표시하십시오. 우리는 마법사가 아닙니다. [SSCCE는 좋을 것입니다] (http://sscce.org/) – atomman