FXCanvas is a component to embed JavaFX content into
SWT applications. The content to be displayed is specified
with the setScene method that accepts an instance of
JavaFX Scene. After the scene is assigned, it gets
repainted automatically. All the input and focus events are
forwarded to the scene transparently to the developer.
Here is a typical pattern how FXCanvas can used:
public class Test {
private static Scene createScene() {
Group group = new Group();
Scene scene = new Scene(group);
Button button = new Button("JFX Button");
group.getChildren().add(button);
return scene;
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
FXCanvas canvas = new FXCanvas(shell, SWT.NONE);
Scene scene = createScene();
canvas.setScene(scene);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
extends