在我的JavaFX实现中,当我点击窗格上的按钮时,我会使用一个窗格,我想打开一个webview。
但是,使用此代码段它不起作用:
"INSERT INTO `Employees`(`fname`, `minitial`, `lname`, `gender`, `phone`, `dob`, `ssn`, `address`, `city`, `state`, `zip`, `email`, `username`, `password`) VALUES('$fname', '$minitial', '$lname', '$gender', '$phone', '$dob', '$ssn', '$address', '$city', '$state', '$zip', '$email', '$username', md5('$password'))"
我有这个叫fxml:
WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
webEngine.load("http://google.com");
button.setOnAction((event) -> {
webEngine.load(url.toExternalForm());
});
任何提示? THX
答案 0 :(得分:0)
您必须将窗格添加到根目录,然后将webview添加到窗格。另外,请查看此按钮处理程序与您的处理程序相比。
Button btn = new Button();
btn.setText("Say 'Hello World'");
WebView webview = new WebView();
WebEngine webengine = webview.getEngine();
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
webengine.load("http://www.google.com");
}
});
VBox root = new VBox();
root.getChildren().addAll(btn, webview);//I don't see where you are doing this
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();