Nickolas, I do not know if this is what you need, but I think so.
JavaFX provides a component called WebView, which with the help of WebEngine can be used to load web pages along with building the DOM and executing the necessary JavaScript.
For Swing applications it provides another component called JFXPanel which can be used to embed JavaFX components in Swing applications and in turn JFXPanel is added to JFrame or other Swing containers.
This example below can be downloaded from the link page. need.
importjavafx.application.Platform;importjavafx.embed.swing.JFXPanel;importjavafx.scene.Scene;importjavafx.scene.layout.BorderPane;importjavafx.scene.web.WebView;importjavax.swing.*;importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;publicclassSwingHtmlDemo{publicstaticvoidmain(String[]args){SwingUtilities.invokeLater(newRunnable(){@Overridepublicvoidrun(){ApplicationFramemainFrame=newApplicationFrame();mainFrame.setVisible(true);}});}}/***MainwindowusedtodisplaysomeHTMLcontent.*/classApplicationFrameextendsJFrame{JFXPaneljavafxPanel;WebViewwebComponent;JPanelmainPanel;JTextFieldurlField;JButtongoButton;publicApplicationFrame(){javafxPanel=newJFXPanel();initSwingComponents();loadJavaFXScene();}/***InstantiatetheSwingcompoentstobeused*/privatevoidinitSwingComponents(){mainPanel=newJPanel();mainPanel.setLayout(newBorderLayout());mainPanel.add(javafxPanel,BorderLayout.CENTER);JPanelurlPanel=newJPanel(newFlowLayout());urlField=newJTextField();urlField.setColumns(50);urlPanel.add(urlField);goButton=newJButton("Go");
/**
* Handling the loading of new URL, when the user
* enters the URL and clicks on Go button.
*/
goButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Platform.runLater(new Runnable() {
@Override
public void run() {
String url = urlField.getText();
if ( url != null && url.length() > 0){
webComponent.getEngine().load(url);
}
}
});
}
});
urlPanel.add(goButton);
mainPanel.add(urlPanel, BorderLayout.NORTH);
this.add(mainPanel);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(700,600);
}
/**
* Instantiate the JavaFX Components in
* the JavaFX Application Thread.
*/
private void loadJavaFXScene(){
Platform.runLater(new Runnable() {
@Override
public void run() {
BorderPane borderPane = new BorderPane();
webComponent = new WebView();
webComponent.getEngine().load("http://google.com/");
borderPane.setCenter(webComponent);
Scene scene = new Scene(borderPane,450,450);
javafxPanel.setScene(scene);
}
});
}
}