Can we add the JavaFX Webview into a container?
Actually I have a project in progress and I would like to have only one windows for ma UI. The "SplitPane" UI might be a good answer for me and functionalities I have to display. (see below)
In the "view" section, I would like to display a WebView, an particulary a map (MapBox or OpenStreetMap) doesn't matter !
Actually my map.html works in an independant window, I only need to know if what I want to do is possible, and if so, can you show me how to do it ?
For now, I have this class :
import java.io.IOException;
import javax.annotation.PostConstruct;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class MapViewer extends Application {
@PostConstruct
public static void main(String[] args) {
launch(args);
}
public void start(Stage stage) {
SplitPane root;
try {
root = (SplitPane) FXMLLoader.load(getClass().getResource("Main.fxml"));
Stage secondStage = new Stage();
Scene scene = new Scene(root, 750, 300);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
secondStage.setScene(scene);
secondStage.setTitle("MapView");
secondStage.sizeToScene();
secondStage.show();
Stage stage1 = new Stage();
WebView webview = new WebView();
webview.getEngine().load(MapViewer.class.getResource("/view mapview3.html").toExternalForm());
stage1.setTitle("MapView");
stage1.setMaximized(true);
stage1.setScene(new Scene(webview));
webview.getEngine().setJavaScriptEnabled(true);
stage1.show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}