내가 내 게임 플레이 패널 그래서 got this sample code재설정 카운트 다운 타이머는 자바 스윙 게임 + JDialog를/JOptionPane에 작동하지 내가 자바 스윙과 좋은 아니에요 내가 타이머 3 초</p> <p>그러나 상기의 지연 게임을 시작 사용하려고 해요
: 나는 대화 상자를 표시 할 같은 시간
그래서 내 대화는 다음과 같다 (또한 게임은 초점이 대화에 있어야하므로 3 초 기다려야합니다) 이 :public class GamePlayPanel extends JPanel implements ActionListener {
// attributes
private JOptionCountDownTimer countDownDialog;
public GamePlayPanel(MainWindow mainWindow) {
// initialization attributes
initLayoutPanel();
this.timer = new Timer(DELAY, this);
// Added a delay of 3 seconds so you can prepare to for the game
this.timer.setInitialDelay(3000);
resetTime();
}
public void startGame() {
this.gamePanel.requestFocus();
this.countDownDialog.startCountDown();
startTimer(); // this is my game timer to record the game time
}
public void restartGame() {
this.countDownDialog.resetCountDown();
startTimer();
this.gamePanel.requestFocus();
}
}
잘 작동하지만 게임을 다시 시작하면 카운트 다운 타이머가 0 -> 2 초에 시작됩니다.
더 좋은 아이디어가 있습니까? JOptionCountDownTimer
? 나는 그것이 JDialog
클래스를 확장하려고 노력했다. 그러나 나는 그것이 작용할 수 없었다.
[이] (http://stackoverflow.com/a/12451673/230513)? – trashgod
예, 코드가 있습니다. – t0tec
문제를 설명하고 [원본] (http://stackoverflow.com/a/12451673/230513)을 인용하는 [mcve] (http://stackoverflow.com/help/mcve)를 포함하도록 질문을 편집하십시오.). – trashgod