Example usage for javafx.scene Group getChildren

List of usage examples for javafx.scene Group getChildren

Introduction

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

Prototype

@Override
public ObservableList<Node> getChildren() 

Source Link

Document

Gets the list of children of this 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);// w w  w.ja  v  a 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();
}

From source file:Main.java

static Node distantLight() {
    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0f);/*w w  w  .jav  a2 s .c  o m*/
    light.setElevation(30.0f);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0f);

    final Text t = new Text();
    t.setText("Distant Light");
    t.setFill(Color.RED);
    t.setFont(Font.font("null", FontWeight.BOLD, 70));
    t.setX(10.0f);
    t.setY(50.0f);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    final Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    Group g = new Group();
    g.getChildren().add(r);
    g.getChildren().add(t);

    g.setTranslateY(460);

    return g;
}

From source file:Main.java

static Node blendMode() {
    Rectangle r = new Rectangle();
    r.setX(590);/*from  w w w  .jav  a2s .c  o m*/
    r.setY(50);
    r.setWidth(50);
    r.setHeight(50);
    r.setFill(Color.BLUE);

    Circle c = new Circle();
    c.setFill(Color.rgb(255, 0, 0, 0.5f));
    c.setCenterX(590);
    c.setCenterY(50);
    c.setRadius(25);

    Group g = new Group();
    g.setBlendMode(BlendMode.MULTIPLY);
    g.getChildren().add(r);
    g.getChildren().add(c);
    return g;
}

From source file:Main.java

static Node displacementMap() {
    int w = 220;/*from   w w  w.j  a v a2s .  c  o m*/
    int h = 100;
    FloatMap map = new FloatMap();
    map.setWidth(w);
    map.setHeight(h);

    for (int i = 0; i < w; i++) {
        double v = (Math.sin(i / 50.0 * Math.PI) - 0.5) / 40.0;
        for (int j = 0; j < h; j++) {
            map.setSamples(i, j, 0.0f, (float) v);
        }
    }

    Group g = new Group();
    DisplacementMap dm = new DisplacementMap();
    dm.setMapData(map);

    Rectangle r = new Rectangle();
    r.setX(20.0f);
    r.setY(20.0f);
    r.setWidth(w);
    r.setHeight(h);
    r.setFill(Color.BLUE);

    g.getChildren().add(r);

    Text t = new Text();
    t.setX(40.0f);
    t.setY(80.0f);
    t.setText("Wavy Text");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font("null", FontWeight.BOLD, 36));

    g.getChildren().add(t);

    g.setEffect(dm);
    g.setCache(true);

    g.setTranslateX(400);
    g.setTranslateY(200);

    return g;
}

From source file:Main.java

static Node bloom() {
    Group g = new Group();

    Rectangle r = new Rectangle();
    r.setX(10);//from w w  w.j  a  v a2 s.co m
    r.setY(10);
    r.setWidth(160);
    r.setHeight(80);
    r.setFill(Color.DARKBLUE);

    Text t = new Text();
    t.setText("Bloom!");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font("null", FontWeight.BOLD, 36));
    t.setX(25);
    t.setY(65);

    g.setCache(true);
    //g.setEffect(new Bloom());
    Bloom bloom = new Bloom();
    bloom.setThreshold(1.0);
    g.setEffect(bloom);
    g.getChildren().add(r);
    g.getChildren().add(t);
    g.setTranslateX(350);
    return g;
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {

    Path path = new Path();
    path.getElements().add(new MoveTo(0.0f, 0.0f));
    path.getElements().add(new HLineTo(80.0f));

    Group root = new Group();
    root.getChildren().add(path);
    primaryStage.setScene(new Scene(root, 300, 250));
    primaryStage.show();//  w  w w  .j a v  a 2 s  .c om
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setEditable(true);/*w  w w.j a v a  2  s  .co  m*/
    myComboBox.setPromptText("Email address");

    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setValue("A");
    System.out.println(myComboBox.getValue());

    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);/* w  w w  . java  2  s .c  om*/
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);

    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setEditable(true);//  w  w  w .  j  a va 2  s.  com

    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ComboBox<String> myComboBox = new ComboBox<String>();
    myComboBox.getItems().addAll("A", "B", "C", "D", "E");
    myComboBox.setValue("A");
    System.out.println(myComboBox.getValue());

    myComboBox.setValue(null);/*from  w w  w  .  j  av a  2 s.c  o m*/

    Group root = (Group) scene.getRoot();
    root.getChildren().add(myComboBox);
    stage.setScene(scene);
    stage.show();
}