Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Get the url to load from the <code>text</code> of the address bar, not the <code>toString</code> of the action event on the address bar.</p> <pre><code>final TextField addressBar = new TextField(); addressBar.setOnAction(new EventHandler&lt;ActionEvent&gt;() { public void handle(ActionEvent event) { myWebEngine.load(addressBar.getText()); } }); </code></pre> <p>Also the load is asynchronous, so your exception handler won't work. You need to monitor's the webengine loadworker's exception property to get exceptions from the engine. Also note that a url not found is not necessarily an exception which would be reported, instead a web server will usually return a page for a http 404 error.</p> <p>Here is a working sample:</p> <pre><code>import javafx.application.Application; import javafx.beans.value.*; import javafx.event.*; import javafx.scene.Scene; import javafx.scene.control.TextField; import javafx.scene.layout.VBox; import javafx.scene.web.*; import javafx.stage.Stage; public class Main extends Application { private WebEngine myWebEngine; public void start(Stage stage) { stage.setTitle("Platinum v1"); final TextField addressBar = new TextField(); addressBar.setOnAction(new EventHandler&lt;ActionEvent&gt;() { public void handle(ActionEvent event) { myWebEngine.load(addressBar.getText()); } }); WebView myBrowser = new WebView(); myWebEngine = myBrowser.getEngine(); myWebEngine.getLoadWorker().exceptionProperty().addListener(new ChangeListener&lt;Throwable&gt;() { @Override public void changed(ObservableValue&lt;? extends Throwable&gt; observableValue, Throwable oldException, Throwable exception) { System.out.println("WebView encountered an exception loading a page: " + exception); } }); VBox root = new VBox(); root.getChildren().setAll( addressBar, myBrowser ); stage.setScene(new Scene(root)); stage.show(); } public static void main(String[] args) { launch(args); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload