我試圖顯示一個標籤,說所有在JRE 8中只有3秒正確,因爲我無法在JRE 7中使用DatePicker,並且我收回了此錯誤。計時器錯誤java.lang.IllegalStateException
Exception in thread "Timer-2" java.lang.IllegalStateException: Not on FX application thread; currentThread = Timer-2
at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source)
at javafx.scene.Scene.addToDirtyList(Unknown Source)
at javafx.scene.Node.addToSceneDirtyList(Unknown Source)
at javafx.scene.Node.impl_markDirty(Unknown Source)
at javafx.scene.Node$7.invalidated(Unknown Source)
at javafx.beans.property.BooleanPropertyBase.markInvalid(Unknown Source)
at javafx.beans.property.BooleanPropertyBase.set(Unknown Source)
at javafx.css.StyleableBooleanProperty.set(Unknown Source)
at javafx.scene.Node.setVisible(Unknown Source)
at Pantallas.PersonalContabilidad$1.run(PersonalContabilidad.java:221)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
correct
是一個標籤,我顯示,3秒鐘,它失敗在correct.setVisible(false);
這是行221
correct.setVisible(true);
timer.schedule(new TimerTask() {
@Override
public void run() {
correct.setVisible(false);
}
}, 3*1000);