5
目前我有一个TextField,它是我的地址栏和一个WebView,它是我的页面。当我点击时,TextField似乎没有做任何事情。它意味着运行loadPage方法并设置为页面来加载用户输入到地址栏中的任何内容。任何帮助,将不胜感激。
JavaFX TextField EventHandler
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<ActionEvent>() {
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.");
}
}
}
你是对的,除了没有设置,那么你将如何检测404回应? – 2013-06-03 10:50:26
请提出一个新的问题,关于从WebView中检测404个Web服务器响应 – jewelsea 2013-06-03 16:39:35