import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.embed.swt.FXCanvas; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class SimpleFXCanvas { private static void createScene(final FXCanvas fxCanvas) { Group root = new Group(); final Scene scene = new Scene(root); scene.setFill(Color.LIGHTGREEN); Rectangle rect = new Rectangle(); rect.setX(25); rect.setY(40); rect.setWidth(100); rect.setHeight(50); rect.setFill(Color.BLUE); root.getChildren().add(rect); // add scene to panel fxCanvas.setScene(scene); } public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setSize(400, 400); shell.setLayout(new FillLayout()); Button button = new Button(shell, SWT.NONE); button.setText("SWT Button (press to close)"); button.addListener(SWT.Selection, new Listener() { public void handleEvent (Event e) { shell.close(); } }); // Create javafx panel final FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE); // create JavaFX scene createScene(fxCanvas); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }