我有循環是這樣的:暫停循環,直到用戶點擊一個按鈕
do{
/* method is randomly choosing next question from database */
/* Question keep possibly answers aswell */
Question question = questionBase.getNextQuestion();
/* creating new panel with label with question and buttons with answers */
QuestionPanel qPanel = new QuestionPanel(question);
/* show panel to user */
myJFrame.setContentPane(qPanel);
myJFrame.validate();
/* wait till user will answer - so when button from panel qPanel is clicked */
/* how?? */
}while(!isEnd());
我曾嘗試是一個簡單的while(qPanel.isAnswered() == false())
循環當我checkign標誌answered
這是對真正的設置被點擊按鈕時。但桂不刷新在所有的Cuz while循環
我試圖把鞦韆工人,但我的主循環DoWhile沒有等待他的執行力,什麼是合理的。
我試圖揮杆定時器但是我的主迴路不回採的。
也許我在錯誤的方式使用它。但是,解決我的問題的最佳方法是什麼?
你需要使用threads.or你可以問下一個問題在用戶回答問題後,你不需要線程 – 2014-12-06 12:40:07