Example usage for javafx.scene Scene heightProperty

List of usage examples for javafx.scene Scene heightProperty

Introduction

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

Prototype

public final ReadOnlyDoubleProperty heightProperty() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Circle c = new Circle();
    Group root = new Group(c);
    Scene scene = new Scene(root, 100, 100);

    c.centerXProperty().bind(scene.widthProperty().divide(2));
    c.centerYProperty().bind(scene.heightProperty().divide(2));
    c.radiusProperty().bind(Bindings.min(scene.widthProperty(), scene.heightProperty()).divide(2));

    stage.setTitle("A Centered Circle");
    stage.setScene(scene);/* w w w. ja va 2  s. c o m*/
    stage.sizeToScene();
    stage.show();
}

From source file:HexTest.java

@Override
public void start(Stage primaryStage) throws InterruptedException, IOException {
    HexArea hexArea = new HexArea();

    Scene scene = new Scene(hexArea, 800, 600);
    hexArea.prefWidthProperty().bind(scene.widthProperty());
    hexArea.prefHeightProperty().bind(scene.heightProperty());

    primaryStage.setScene(scene);/*from  w w w.j a  va2 s . com*/
    primaryStage.setTitle("HexTest");
    primaryStage.show();

    hexArea.setContent(IOUtils.toByteArray(new FileInputStream("a.class")));
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {

    BorderPane bp = new BorderPane();
    bp.setPadding(new Insets(10, 50, 50, 50));
    Scene scene = new Scene(bp);
    primaryStage.setScene(scene);/*from   w  w w  .  ja  v a  2 s  .c  om*/
    primaryStage.titleProperty()
            .bind(scene.widthProperty().asString().concat(" : ").concat(scene.heightProperty().asString()));

    primaryStage.show();
}

From source file:Main.java

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

    SplitPane splitPane = new SplitPane();
    splitPane.prefWidthProperty().bind(scene.widthProperty());
    splitPane.prefHeightProperty().bind(scene.heightProperty());

    VBox leftArea = new VBox(10);
    HBox rowBox = new HBox(20);
    final Text leftText = TextBuilder.create().text("Left ").translateX(20).fill(Color.RED)
            .font(Font.font(null, FontWeight.BOLD, 20)).build();

    rowBox.getChildren().add(leftText);//from w  w  w . ja  v  a  2  s . c  om
    leftArea.getChildren().add(rowBox);

    leftArea.setAlignment(Pos.CENTER);

    SplitPane splitPane2 = new SplitPane();
    splitPane2.setOrientation(Orientation.VERTICAL);
    splitPane2.prefWidthProperty().bind(scene.widthProperty());
    splitPane2.prefHeightProperty().bind(scene.heightProperty());

    HBox centerArea = new HBox();

    final Text upperRight = TextBuilder.create().text("Text").x(100).y(50).fill(Color.RED)
            .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build();
    centerArea.getChildren().add(upperRight);

    HBox rightArea = new HBox();

    final Text lowerRight = TextBuilder.create().text("Lower Right").x(100).y(50).fill(Color.RED)
            .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build();
    rightArea.getChildren().add(lowerRight);

    splitPane2.getItems().add(centerArea);
    splitPane2.getItems().add(rightArea);

    splitPane.getItems().add(leftArea);

    splitPane.getItems().add(splitPane2);

    ObservableList<SplitPane.Divider> dividers = splitPane.getDividers();
    for (int i = 0; i < dividers.size(); i++) {
        dividers.get(i).setPosition((i + 1.0) / 3);
    }
    HBox hbox = new HBox();
    hbox.getChildren().add(splitPane);
    root.getChildren().add(hbox);

    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, 551, 400, Color.BLACK);
    Group buttonGroup = new Group();
    Arc rightButton = ArcBuilder.create().type(ArcType.ROUND).radiusX(15).radiusY(15).startAngle(180 - 30)
            .length(60).translateX(40).build();
    buttonGroup.getChildren().add(rightButton);
    buttonGroup.translateYProperty().bind(scene.heightProperty().subtract(10));
    root.getChildren().add(buttonGroup);

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

    Arc arc = new Arc();
    arc.setCenterX(50.0f);/*  ww  w. j  a va 2 s  . co  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);

    g.getChildren().add(arc);

    arc.centerXProperty().bind(scene.heightProperty().subtract(10));

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

From source file:Main.java

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

    TabPane tabPane = new TabPane();

    BorderPane borderPane = new BorderPane();
    for (int i = 0; i < 5; i++) {
        Tab tab = new Tab();
        tab.setText("Tab" + i);
        HBox hbox = new HBox();
        hbox.getChildren().add(new Label("Tab" + i));
        hbox.setAlignment(Pos.CENTER);//ww  w  .j  a va2  s  .co m
        tab.setContent(hbox);
        tabPane.getTabs().add(tab);
    }
    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setCenter(tabPane);
    root.getChildren().add(borderPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

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

    TabPane tabPane = new TabPane();

    BorderPane borderPane = new BorderPane();
    for (int i = 0; i < 5; i++) {
        Tab tab = new Tab();
        tab.setText("Tab" + i);
        HBox hbox = new HBox();
        hbox.getChildren().add(new Label("Tab" + i));
        hbox.setAlignment(Pos.CENTER);//w  ww  . j  a v a  2 s.  com
        tab.setContent(hbox);
        tabPane.getTabs().add(tab);
    }
    tabPane.setSide(Side.LEFT);
    //tabPane.setSide(Side.TOP);
    //tabPane.setSide(Side.RIGHT);
    //tabPane.setSide(Side.BOTTOM);

    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setCenter(tabPane);
    root.getChildren().add(borderPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

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

    MenuBar menuBar = new MenuBar();
    EventHandler<ActionEvent> action = changeTabPlacement();

    Menu menu = new Menu("Direction");
    MenuItem left = new MenuItem("Left");

    left.setOnAction(action);/* w w  w  . jav  a2 s . co  m*/
    menu.getItems().add(left);

    MenuItem right = new MenuItem("Right");
    right.setOnAction(action);
    menu.getItems().add(right);

    MenuItem top = new MenuItem("Top");
    top.setOnAction(action);
    menu.getItems().add(top);

    MenuItem bottom = new MenuItem("Bottom");
    bottom.setOnAction(action);
    menu.getItems().add(bottom);

    menuBar.getMenus().add(menu);

    BorderPane borderPane = new BorderPane();

    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setTop(menuBar);

    root.getChildren().add(borderPane);

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

From source file:org.jamocha.gui.JamochaGui.java

private Scene generateScene() {
    final TabPane tabPane = new TabPane();
    tabPane.setSide(Side.LEFT);/*from  w w  w.j  a v  a 2  s.c om*/

    this.log = new TextArea();
    final Tab logTab = new Tab("Log");
    logTab.setContent(this.log);
    logTab.setClosable(false);

    final Tab networkTab = new Tab("Network");
    networkTab.setClosable(false);
    final ScrollPane scrollPane = new ScrollPane();
    networkTab.setContent(scrollPane);

    this.networkVisualisation = new NetworkVisualisation(this.jamocha.getNetwork());
    this.networkVisualisation.setTranslateX(10);
    this.networkVisualisation.setTranslateY(10);
    this.networkVisualisation.update();
    scrollPane.setContent(this.networkVisualisation);

    tabPane.getTabs().addAll(logTab, networkTab);

    final Scene scene = new Scene(tabPane);
    tabPane.prefHeightProperty().bind(scene.heightProperty());
    tabPane.prefWidthProperty().bind(scene.widthProperty());
    return scene;
}