0

I am attempting to re create a simple JFrame with several textFields, a submit and clear button, just like figure 8-2 in the following tutorial:

http://docs.oracle.com/javafx/2/ui_controls/text-field.htm

But I keep getting an error:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: Toolkit not initialized

At this line of code:

final TextField totTime = new TextField();

I am somewhat new to using Javafx, so why am I given this error? Thanks!

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);
}
Sean
  • 1,283
  • 9
  • 27
  • 43
  • 2
    Could you try this answer http://stackoverflow.com/questions/11273773/javafx-2-1-toolkit-not-initialized? – Tunaki Jun 07 '16 at 14:51
  • Are you trying to write a Swing application or a JavaFX application? You mention JFrame (which is a Swing window), but then you linked documentation for JavaFX. If you are trying to mix the two, why? It is much simpler just to use one toolkit. Also note the documentation you linked is from a previous version of JavaFX. Up-to-date documentation for both Swing and JavaFX can be found [here](http://docs.oracle.com/javase/8/javase-clienttechnologies.htm) – James_D Jun 07 '16 at 15:27

0 Answers0