List of usage examples for javafx.scene Scene Scene
public Scene(@NamedArg("root") Parent root, @NamedArg(value = "fill", defaultValue = "WHITE") Paint fill)
From source file:TwoButtons.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); final RowLayout layout = new RowLayout(); shell.setLayout(layout);/*from ww w .ja va 2 s .c o m*/ /* Create the SWT button */ final org.eclipse.swt.widgets.Button swtButton = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH); swtButton.setText("SWT Button"); /* Create an FXCanvas */ final FXCanvas fxCanvas = new FXCanvas(shell, SWT.NONE) { public Point computeSize(int wHint, int hHint, boolean changed) { getScene().getWindow().sizeToScene(); int width = (int) getScene().getWidth(); int height = (int) getScene().getHeight(); return new Point(width, height); } }; /* Create a JavaFX Group node */ Group group = new Group(); /* Create a JavaFX button */ final Button jfxButton = new Button("JFX Button"); /* Assign the CSS ID ipad-dark-grey */ jfxButton.setId("ipad-dark-grey"); /* Add the button as a child of the Group node */ group.getChildren().add(jfxButton); /* Create the Scene instance and set the group node as root */ Scene scene = new Scene(group, Color.rgb(shell.getBackground().getRed(), shell.getBackground().getGreen(), shell.getBackground().getBlue())); /* Attach an external stylesheet */ scene.getStylesheets().add("twobuttons/Buttons.css"); fxCanvas.setScene(scene); /* Add Listeners */ swtButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { jfxButton.setText("JFX Button: Hello from SWT"); shell.layout(); } }); jfxButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { swtButton.setText("SWT Button: Hello from JFX"); shell.layout(); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }