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 primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

    TextField textBox = new TextField();
    textBox.setPromptText("Write here");
    // Define an event filter
    EventHandler filter = new EventHandler<InputEvent>() {
        public void handle(InputEvent event) {
            System.out.println("Filtering out event " + event.getEventType());
            event.consume();//from ww  w.jav  a 2 s.  co m
        }
    };
    // Register the same filter for two different nodes
    scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter);

    // Register the filter for another event type
    scene.addEventFilter(KeyEvent.KEY_PRESSED, filter);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Menus");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    MenuBar menuBar = new MenuBar();

    Menu tools = new Menu("Your Menu");
    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 1").selected(true).build());

    tools.getItems().add(CheckMenuItemBuilder.create().text("Item 2").selected(true).build());
    menuBar.getMenus().add(tools);// w w w.ja  v  a 2  s.c  om

    menuBar.prefWidthProperty().bind(primaryStage.widthProperty());

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Shapes");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 300, Color.WHITE);

    Ellipse bigCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(50).radiusY(75 / 2)
            .strokeWidth(3).stroke(Color.BLACK).fill(Color.WHITE).build();

    Ellipse smallCircle = EllipseBuilder.create().centerX(100).centerY(100).radiusX(35 / 2).radiusY(25 / 2)

            .build();//from   w  ww. j av a 2s. c om

    Shape shape = Path.subtract(bigCircle, smallCircle);
    shape.setStrokeWidth(1);
    shape.setStroke(Color.BLACK);

    shape.setFill(Color.rgb(255, 200, 0));

    root.getChildren().add(shape);

    primaryStage.setScene(scene);
    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");
    // Define an event filter
    EventHandler filter = new EventHandler<InputEvent>() {
        public void handle(InputEvent event) {
            System.out.println("Filtering out event " + event.getEventType());
            event.consume();/*from w  w w. j  a  v a2s .  co m*/
        }
    };
    // Register the same filter for two different nodes
    scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter);

    // Register the filter for another event type
    scene.addEventFilter(KeyEvent.KEY_PRESSED, filter);

    scene.removeEventFilter(MouseEvent.MOUSE_PRESSED, filter);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(300);/* w  ww .ja  v  a2 s  . c o m*/
    stage.setHeight(150);

    Button button = new Button("Hover Over Me");
    Tooltip toolTip = new Tooltip();
    toolTip.setContentDisplay(ContentDisplay.BOTTOM);

    button.setTooltip(toolTip);
    ((Group) scene.getRoot()).getChildren().add(button);

    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, 551, 400, Color.BLACK);
    Group buttonGroup = new Group();
    Arc rightButton = ArcBuilder.create().type(ArcType.ROUND).centerX(12).centerY(16).radiusX(15).radiusY(15)
            .startAngle(180 - 30).length(60).fill(new Color(1, 1, 1, .90)).translateX(40).build();
    buttonGroup.getChildren().add(rightButton);
    root.getChildren().add(buttonGroup);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);//  www .  j a  v  a 2  s. c o m
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setVgap(0.6);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);/* w w  w.j  a  v a 2  s.c  om*/
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setTileAlignment(Pos.BASELINE_CENTER);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);//from   w w w .  j  a v  a  2 s.  c o  m
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setPrefTileHeight(0.8);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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

From source file:Main.java

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

    TilePane tile = new TilePane();

    tile.setHgap(8);/*www  .  j  av a  2s .co  m*/
    tile.setPrefColumns(4);
    for (int i = 0; i < 20; i++) {
        tile.getChildren().add(new CheckBox("CheckBox"));
    }
    tile.setPrefColumns(8);

    HBox hbox = new HBox(10);
    hbox.setPadding(new Insets(20, 0, 0, 20));
    hbox.getChildren().setAll(tile);

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