2011-05-04 14 views

回答

4

http://download.oracle.com/javase/6/docs/api/javax/swing/Timer.html

這可讓您在Swing事件線程與指定的延遲反覆執行一個ActionListener。

剛剛從文本字段中獲取並設置值。

編輯:不是Runnable,而是動作偵聽器

+0

快速響應。這可能意味着我在Google上搜索得不好。謝謝。 – davidahines 2011-05-04 18:19:34

+0

爲(1000)做一個Thread.sleep是否準確,然後只需要添加一個更新該字段? – davidahines 2011-05-04 18:22:26

+2

不,您通常不想使用Thread.sleep(),因爲這會同時阻止您的用戶界面。如果您只想調用一次,請調用timer.setRepeats(false)。 – 2011-05-04 18:30:18