import java.awt.Color; import javafx.application.Application; import javafx.embed.swing.SwingNode; import javafx.scene.Scene; import javafx.scene.layout.StackPane; import javafx.stage.Stage; import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.SwingUtilities; public final class Test extends Application { public static void main(String[] args) { launch(args); } private void initSwing(final SwingNode swingNode) { SwingUtilities.invokeLater(new Runnable() { public void run() { JPanel panel = new JPanel(); JButton button = new JButton("Ok"); button.setBackground(Color.RED); panel.add(button); swingNode.setContent(panel); } }); } @Override public void start(Stage stage) throws Exception { final SwingNode swingNode = new SwingNode(); initSwing(swingNode); StackPane pane = new StackPane(); pane.setStyle("-fx-background-color: #00FF00"); pane.getChildren().add(swingNode); Scene scene = new Scene(pane, 300, 300); stage.setScene(scene); stage.setTitle("Button Embedded in JavaFX"); stage.show(); } }