title: JavaFX TextField EventHandler
body: <p>Currently I have a TextField which is my address bar and a WebView which is my page. When I click ented the TextField doesn't seem to do anything. It's meant to run the loadPage method and set to page to load whatever the user entered into the address bar. Any help would be appreciated.<br></p>
  
  <pre><code>package javafx_webview;
  
  import javafx.application.Application;
  import javafx.event.ActionEvent;
  import javafx.event.EventHandler;
  import javafx.scene.Scene;
  import javafx.scene.control.TextField;
  import javafx.scene.layout.StackPane;
  import javafx.scene.web.WebEngine;
  import javafx.scene.web.WebView;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      WebEngine myWebEngine;
  
      public static void main(String[] args) {
          launch(args);
      }
  
      public void start(Stage primaryStage) {
          primaryStage.setTitle("Platinum v1");
  
          TextField addressBar = new TextField();
  
          addressBar.setOnAction(new EventHandler&lt;ActionEvent&gt;() {
              public void handle(ActionEvent event) {
                  loadPage(event.toString());
              }
          });
  
          WebView myBrowser = new WebView();
          myWebEngine = myBrowser.getEngine();
  
          StackPane root = new StackPane();
          root.getChildren().add(myBrowser);
          root.getChildren().add(addressBar);
          primaryStage.setScene(new Scene(root, 640, 480));
          primaryStage.show();
      }
  
      private void loadPage(String url) {
          try {
              myWebEngine.load(url);
          } catch (Exception e) {
              System.out.println("The URL you requested could not be found.");
          }
      }
  }
  </code></pre>