我正在尝试使用几个textFields,一个提交和清除按钮重新创建一个简单的JFrame,就像下面教程中的图8-2一样:
http://docs.oracle.com/javafx/2/ui_controls/text-field.htm
但我一直收到错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: Toolkit not initialized
在这行代码中:
final TextField totTime = new TextField();
我对使用Javafx有些新意,为什么我会给出这个错误?谢谢!
public static void main(String[] args) throws IOException
{
//Creating GridPane container
GridPane grid = new GridPane();
grid.setPadding(new Insets(10, 10, 10, 10));
grid.setVgap(5);
grid.setHgap(5);
//Defining Total Time
final TextField totTime = new TextField();
totTime.setPromptText("Enter Simulation Duration (Double)");
totTime.setPrefColumnCount(5);
totTime.getText();
GridPane.setConstraints(totTime, 0, 0);
grid.getChildren().add(totTime);
//Defining the Submit button
Button submit = new Button("Submit");
GridPane.setConstraints(submit, 1, 0);
grid.getChildren().add(submit);
//Defining the Clear button
Button clear = new Button("Clear");
GridPane.setConstraints(clear, 1, 1);
grid.getChildren().add(clear);
}