Example usage for javafx.scene Group Group

List of usage examples for javafx.scene Group Group

Introduction

In this page you can find the example usage for javafx.scene Group Group.

Prototype

public Group() 

Source Link

Document

Constructs a group.

Usage

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);/* ww w . jav  a 2  s .  com*/

    /* 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();
}

From source file:Main.java

private static void initFX(JFXPanel fxPanel) {
    final Group rootGroup = new Group();
    final Scene scene = new Scene(rootGroup, 800, 400, Color.BEIGE);

    fxPanel.setScene(scene);//from w w w.j a  v a 2  s  .  co  m
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 600, 400);
    stage.setScene(scene);/*from w  ww .j  ava2 s .  c o  m*/
    stage.setTitle("Slider Sample");

    Slider slider = new Slider(0, 1, 0.5);
    root.getChildren().add(slider);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);/*  w w  w.  ja va2s  .  c o  m*/

    Group g = new Group();

    Polygon polygon = new Polygon(0.0, 0.0, 20.0, 10.0, 10.0, 20.0);

    g.getChildren().add(polygon);

    scene.setRoot(g);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 200);
    stage.setScene(scene);/* ww w. j  a v a2 s. c o m*/

    Rectangle rect = new Rectangle(100, 100);
    rect.setLayoutX(50);
    rect.setLayoutY(50);
    rect.setStyle("-fx-fill: red; ");
    ((Group) scene.getRoot()).getChildren().add(rect);

    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);// www  . j  a  va2  s . c  om

    Group g = new Group();

    Polygon polygon = new Polygon();
    polygon.getPoints().addAll(new Double[] { 0.0, 0.0, 20.0, 10.0, 10.0, 20.0 });

    g.getChildren().add(polygon);

    scene.setRoot(g);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);/*from  w w  w .  jav a 2 s .co  m*/

    Group g = new Group();

    Polyline polyline = new Polyline();
    polyline.getPoints().addAll(new Double[] { 0.0, 0.0, 20.0, 10.0, 10.0, 20.0 });

    g.getChildren().add(polyline);

    scene.setRoot(g);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Group group = new Group();
    Scene scene = new Scene(group, 300, 150);
    stage.setScene(scene);//from  ww  w  .j a v a2s  . c  om
    stage.setTitle("Sample");

    SVGPath svg = new SVGPath();
    svg.setContent("M40,60 C42,48 44,30 25,32");

    group.getChildren().add(svg);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//from   w  ww.ja va  2 s  .co m
    stage.setTitle("Sample");

    Task<Void> task = new Task<Void>() {
        @Override
        protected Void call() throws Exception {
            return null;
        }
    };

    task.run();
    System.out.println(task.getMessage());

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);/*www.jav  a 2  s . c om*/

    Group g = new Group();

    Polygon polygon = new Polygon(0.0, 0.0, 20.0, 10.0, 10.0, 20.0);

    g.getChildren().add(polygon);

    System.out.println(polygon.getPoints());

    scene.setRoot(g);
    stage.show();
}