I'm migrating an old legacy application from in browser applet to a JFrame based JWS application started via JNLP.
In the applet base application I used the context.showDocument()
to open Browser windows of any size and configured to not show bars (menu bar, status-bar, scroll bar) and not resizable (viawith Javascript ()).
But now this is not working.
Is there a workaround for that that I can do in a JavaWebStart/JNLP application?
I would need to open a HTML page and display the contend in a sized window without the usual bars.
When I use the showDocument()
form JNLP basicServices now I can not do this (no JavaScript).
It should normally be possible to preview the html file inside a javafx webview, as it is with a normal java application. I am not sure about the jnlp permissions required for this operation though:
private void previewHtml(String url) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
JFrame fr = new JFrame();
final JFXPanel fxPanel = new JFXPanel();
fr.add(fxPanel);
fr.setSize(1000, 600);
fr.setVisible(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
final Group rootGroup = new Group();
final Scene scene = new Scene(rootGroup, 1000, 600, Color.WHITE);
final WebView webView = WebViewBuilder.create().prefHeight(600).prefWidth(1000).build();
webView.getEngine().load(url);
rootGroup.getChildren().add(webView);
fxPanel.setScene(scene);
fxPanel.show();
}
});
}
});
}
//You can add the following code to a button actionListener:
//prevew html from classpath:
previewHtml(getClass().getResource("/classpath-file.html").toExternalForm());
//prevew html from url:
previewHtml("https://stackoverflow.com/");