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: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);//  ww  w .j av a  2  s. c  o m

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

}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);
    // 5 pixels space between child nodes
    HBox hbox = new HBox(5);
    // 1 pixel padding between child nodes only
    hbox.setPadding(new Insets(1));
    Rectangle r1 = new Rectangle(10, 10);
    Rectangle r2 = new Rectangle(20, 100);
    Rectangle r3 = new Rectangle(50, 20);
    Rectangle r4 = new Rectangle(20, 50);

    HBox.setMargin(r1, new Insets(2, 2, 2, 2));

    hbox.getChildren().addAll(r1, r2, r3, r4);
    root.getChildren().add(hbox);//www  .j a v  a 2s  .  co m

    primaryStage.setScene(scene);
    primaryStage.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);//w ww.  jav a 2s . c o  m

    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) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 150);
    stage.setScene(scene);//  w  w  w . ja v  a2s .c om
    stage.setTitle("Text Field Sample");

    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(5);
    grid.setHgap(5);

    scene.setRoot(grid);

    final TextField name = new TextField();
    name.setPromptText("Enter your first name.");
    name.setPrefColumnCount(10);
    name.getText();
    GridPane.setConstraints(name, 0, 0);
    grid.getChildren().add(name);

    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group group = new Group();

    Button button = new Button("Button");

    button.setStyle("-fx-font-size: 14px;");

    group.getChildren().add(button);/*w ww. j  a v  a 2 s .  co  m*/

    Scene scene = new Scene(group, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group group = new Group();

    Button button = new Button("Button");

    button.setStyle("-fx-padding: 10 20 10 20;");

    group.getChildren().add(button);//from   w w w .j av a  2 s . c  o m

    Scene scene = new Scene(group, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.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);/* ww  w  .  j ava2  s. c  o  m*/
    stage.setTitle("");

    Path path = new Path();

    MoveTo moveTo = new MoveTo();
    moveTo.setX(0.0f);
    moveTo.setY(50.0f);

    QuadCurveTo quadTo = new QuadCurveTo();
    quadTo.setControlX(25.0f);
    quadTo.setControlY(0.0f);
    quadTo.setX(50.0f);
    quadTo.setY(50.0f);

    path.getElements().add(moveTo);
    path.getElements().add(quadTo);

    root.getChildren().add(path);

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

From source file:Main.java

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

    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(new Button("Button One"));
    final StackPane sp2 = new StackPane();
    sp2.getChildren().add(new Button("Button Two"));
    final StackPane sp3 = new StackPane();
    sp3.getChildren().add(new Button("Button Three"));
    sp.getItems().addAll(sp1, sp2, sp3);
    sp.setDividerPositions(0.3f, 0.6f, 0.9f);

    group.getChildren().add(sp);//from w ww . j  ava  2 s.co  m

    stage.setTitle("Welcome to JavaFX!");
    stage.setScene(scene);
    stage.sizeToScene();
    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 v  a  2s  . c  o  m*/
    stage.setTitle("Sample");

    Task<ObservableList<String>> task = new Task<ObservableList<String>>() {
        @Override
        protected ObservableList<String> call() throws Exception {
            updateMessage("message");
            ObservableList<String> results = FXCollections.observableArrayList();
            for (int i = 0; i < 10; i++) {
                if (isCancelled())
                    break;
                results.add("");
                updateProgress(i, 100);
            }
            return results;
        }
    };
    task.run();
    System.out.println(task.getMessage());

    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  w  w  w .ja va 2 s  .c o m*/
    stage.setTitle("Sample");

    Task<Void> task = new Task<Void>() {
        @Override
        protected Void call() throws Exception {
            for (int i = 0; i < 10; i++) {
                if (isCancelled())
                    break;
                final Rectangle r = new Rectangle(10, 10);
                r.setX(10 * i + i);
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        group.getChildren().add(r);
                    }
                });
            }
            return null;
        }
    };
    task.run();
    System.out.println(task.getMessage());

    stage.show();
}