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:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 260);

    Rectangle roundRect = new Rectangle(50, 50, 400, 130);

    roundRect.setArcWidth(30);//from w  w w . j a  v  a  2s. co m
    roundRect.setArcHeight(60);

    roundRect.setFill(null);
    roundRect.setStroke(Color.DARKORANGE);
    roundRect.setStrokeWidth(2);
    roundRect.setStrokeLineCap(StrokeLineCap.BUTT);

    root.getChildren().add(roundRect);

    Slider slider = new Slider(30, 150, 30);
    slider.setLayoutX(250 - slider.getWidth() / 2);
    slider.setLayoutY(115 - slider.getHeight() / 2);

    slider.widthProperty().addListener((ov, curVal, newVal) -> {
        slider.setLayoutX(250 - slider.getWidth() / 2);
    });

    slider.heightProperty()
            .addListener((ov, curVal, newVal) -> slider.setLayoutY(115 - slider.getHeight() / 2));

    roundRect.arcWidthProperty().bind(slider.valueProperty());

    root.getChildren().add(slider);

    Slider slider2 = new Slider(10, 120, 50);
    slider2.setLayoutX(50);
    slider2.setLayoutY(230);

    slider2.widthProperty().addListener((ov, curVal, newVal) -> {
        slider2.setLayoutX(250 - slider2.getWidth() / 2);
    });

    roundRect.yProperty().bind(slider2.valueProperty());
    root.getChildren().add(slider2);

    slider2.valueProperty().addListener((ov, curVal, newVal) -> slider
            .setLayoutY(slider.getLayoutY() + newVal.doubleValue() - curVal.doubleValue()));
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    Arc arc = new Arc(30, 30, 30, 30, 30, 30);
    arc.setCenterX(50.0f);//from  w w w.  j a  v a  2 s .c  o m
    arc.setCenterY(50.0f);
    arc.setRadiusX(25.0f);
    arc.setRadiusY(25.0f);
    arc.setStartAngle(45.0f);
    arc.setLength(270.0f);
    arc.setType(ArcType.ROUND);

    System.out.println(arc.centerYProperty().doubleValue());

    g.getChildren().add(arc);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    Arc arc = new Arc(30, 30, 30, 30, 30, 30);
    arc.setCenterX(50.0f);/*ww w . j a v a 2 s .  com*/
    arc.setCenterY(50.0f);
    arc.setRadiusX(25.0f);
    arc.setRadiusY(25.0f);
    arc.setStartAngle(45.0f);
    arc.setLength(270.0f);
    arc.setType(ArcType.ROUND);

    System.out.println(arc.centerXProperty().doubleValue());

    g.getChildren().add(arc);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    TitledPane t1 = new TitledPane("T1", new Button("B1"));
    TitledPane t2 = new TitledPane("T2", new Button("B2"));
    TitledPane t3 = new TitledPane("T3", new Button("B3"));
    Accordion accordion = new Accordion();
    accordion.getPanes().addAll(t1, t2, t3);

    TitledPane titledPane = accordion.getExpandedPane();

    g.getChildren().add(accordion);

    primaryStage.setScene(scene);/*from w  w  w.ja  v a2  s .  co m*/
    primaryStage.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);/*from  w w w .  j  a v a  2s  . com*/

    Rectangle rect = new Rectangle(100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(Color.VIOLET);

    ScaleTransition st = new ScaleTransition(Duration.millis(2000), rect);
    st.setByX(1.5f);
    st.setByY(1.5f);
    st.setAutoReverse(true);

    st.play();

    root.getChildren().add(rect);

    stage.show();

}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

    TextField textBox = new TextField();
    textBox.setPromptText("Write here");

    // Register an event handler for a single node and a specific event type
    scene.addEventHandler(DragEvent.DRAG_ENTERED, new EventHandler<DragEvent>() {
        public void handle(DragEvent e) {
            System.out.println("drag enter");
        }//from  w  w w.j a v a2  s.  c om
    });

    root.getChildren().add(textBox);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    TitledPane t1 = new TitledPane("T1", new Button("B1"));
    TitledPane t2 = new TitledPane("T2", new Button("B2"));
    TitledPane t3 = new TitledPane("T3", new Button("B3"));
    Accordion accordion = new Accordion();
    accordion.getPanes().addAll(t1, t2, t3);

    ObservableList<TitledPane> paneList = accordion.getPanes();

    g.getChildren().add(accordion);

    primaryStage.setScene(scene);/*w  w  w  .j  a v a  2 s. c o  m*/
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

    TextField textBox = new TextField();
    textBox.setPromptText("Write here");

    // Register an event filter for a single node and a specific event type
    scene.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
        public void handle(MouseEvent e) {
            System.out.println("mouse clicked");
        };/*from  w  w w  . ja  v  a2 s  .  c om*/
    });

    root.getChildren().add(textBox);
    primaryStage.setScene(scene);
    primaryStage.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 w  ww .ja v a2 s.  co  m*/
    stage.setTitle("Sample");

    Rectangle rect = new Rectangle(100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(null);

    StrokeTransition st = new StrokeTransition(Duration.millis(3000), rect, Color.RED, Color.BLUE);

    st.setAutoReverse(true);

    st.play();

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250, Color.web("0x0000FF", 1.0));

    TitledPane t1 = new TitledPane("T1", new Button("B1"));
    TitledPane t2 = new TitledPane("T2", new Button("B2"));
    TitledPane t3 = new TitledPane("T3", new Button("B3"));
    Accordion accordion = new Accordion();
    accordion.getPanes().addAll(t1, t2, t3);

    ObjectProperty<TitledPane> p = accordion.expandedPaneProperty();

    g.getChildren().add(accordion);

    primaryStage.setScene(scene);//from  ww  w  .jav  a2 s . c  o m
    primaryStage.show();
}