错误:Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = main
Exception in thread "main" java.lang.IllegalStateException: Toolkit not initialized
一、错误现象
在运行javafx程序时,我定义了一个类VideoScreenRecordApplication,用于显示写好的javafx界面,为了方便外部调用,这个类没有继承Application,在类中,写了一个show方法,在show方法中,new Stage(),然后定义加载界面各组件。
调用出错的代码如下:
public static void main(String[] args) {
VideoScreenRecordApplication application = new VideoScreenRecordApplication();
application.show();
}
运行后报错: