import javax.swing.JFrame; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.geometry.HPos; import javafx.geometry.VPos; import javafx.scene.Scene; import javafx.scene.layout.Pane; import javafx.scene.web.WebView; import javax.swing.SwingUtilities; public class FXInSwing { private static final int WIDTH = 800; private static final int HEIGHT = 500; public FXInSwing() { initGUI(); } public void initGUI() { final JFXPanel panel = new JFXPanel(); JFrame frame = new JFrame("JavaFX in Swing"); frame.add(panel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setSize(WIDTH, HEIGHT); frame.setLocationRelativeTo(null); Platform.runLater(() -> initJFXPanel(panel)); frame.setVisible(true); } private void initJFXPanel(JFXPanel panel) { Scene scene = new Scene(new Browser(), WIDTH, HEIGHT); panel.setScene(scene); } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new FXInSwing()); } } class Browser extends Pane { final WebView view = new WebView(); public Browser() { view.getEngine().load("https://yourwebs.de"); getChildren().add(view); } @Override protected void layoutChildren() { double w = getWidth(); double h = getHeight(); layoutInArea(view, 0, 0, w, h, 0, HPos.CENTER, VPos.CENTER); } }