The following code creates a Java Swing JFrame with a button which opens a JavaFX WebView inside a dialog, however when opened the web view is blank instead of displaying contents (either the URL contents or "Welcome JavaFX!"). What could be wrong?
(Note: The code is based on this and this).
OpenUrlInJFrameAction.java:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.util.Objects;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.web.WebView;
public class OpenUrlInJFrameAction implements ActionListener {
    private final JFrame parent;
    private final URI uri;
    public OpenUrlInJFrameAction(JFrame parent, URI uri) {
        this.parent = Objects.requireNonNull(parent);
        this.uri = Objects.requireNonNull(uri);
    }
    @Override
    public void actionPerformed(ActionEvent event) {
        SwingUtilities.invokeLater(() -> {
            // You should execute this part on the Event Dispatch Thread
            // because it modifies a Swing component
            JDialog jDialog = new JDialog(parent, true);
            JFXPanel jfxPanel = new JFXPanel();
            jDialog.add(jfxPanel);
            jDialog.setSize(800, 600);
            jDialog.setLocationRelativeTo(null);
            jDialog.setVisible(true);
            // Creation of scene and future interactions with JFXPanel
            // should take place on the JavaFX Application Thread
            Platform.runLater(() -> {
                // Uncomment either the lines below Test 1 or below Test 2, 
                // both are apparently ignored by the web view.
                // Test 1
                Scene scene = createScene();
                jfxPanel.setScene(scene);                  
                // Test 2
                /*WebView webView = new WebView();
                jfxPanel.setScene(new Scene(webView));
                webView.getEngine().load(uri.toString());*/
            });
        });
    }
    private Scene createScene() {
        Group root = new Group();
        Scene scene = new Scene(root, Color.ALICEBLUE);
        Text text = new Text();
        text.setX(40);
        text.setY(100);
        text.setFont(new Font(25));
        text.setText("Welcome JavaFX!");
        root.getChildren().add(text);
        return (scene);
    }      
}
JFrameTest.java:
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class JFrameTest extends JFrame {
    public JFrameTest(String title) {
        super(Objects.requireNonNull(title));
    }
    public static void main(String [] args) {
        SwingUtilities.invokeLater(() -> {
            JFrameTest jFrameTest = new JFrameTest("Test");
            jFrameTest.setDefaultCloseOperation(EXIT_ON_CLOSE);
            JButton jButton = new JButton("Open dialog");
            try {
                jButton.addActionListener(new OpenUrlInJFrameAction(jFrameTest,
                        new URI("https://stackoverflow.com")));
            } catch (URISyntaxException e) {
                throw new RuntimeException(e);
            }
            jFrameTest.add(jButton);
            jFrameTest.pack();
            jFrameTest.setVisible(true);
        });
    }
}
 
    

