Why does my jPanel doesn't show an embed webView from Java FX?

30 Views Asked by At

I don't know much about JavaFX, but I need to show a WebView onto a JPanel in a JFrame. Here's my code

public class Ventana extends javax.swing.JFrame {


        JFXPanel jfxPanel = new JFXPanel();

        
    public Ventana() {
        initComponents();
        
        panel.add(jfxPanel);
        Platform.runLater(() -> {
            WebView webView = new WebView();
            jfxPanel.setScene(new Scene(webView));
            webView.getEngine().load("http://www.stackoverflow.com/");
        });
    }
}

This is my main method from where I'm opening my jFrame

public static void main(String[] args) {
        
        Ventana jf_ventana = new Ventana();
        jf_ventana.setVisible(true);
        
    }

The code I used says this

// Creation of scene and future interactions with JFXPanel
// should take place on the JavaFX Application Thread 
Platform.runLater(() -> {
        WebView webView = new WebView();
        jfxPanel.setScene(new Scene(webView));
        webView.getEngine().load("http://www.stackoverflow.com/");
    });

It doesn't crash or anything, but is not showing anything either

0

There are 0 best solutions below