/** Entry point for the JavaFX application. Configure & show the stage. */
  @Override
  public void start(Stage primaryStage) {

    primaryStage.setTitle("CSSem - Lambda Expression Examples");

    primaryStage.setMinWidth(JavaFXClass.MIN_WIDTH);
    primaryStage.setMaxWidth(JavaFXClass.MAX_WIDTH);
    primaryStage.setMinHeight(JavaFXClass.MIN_HEIGHT);
    primaryStage.setMaxHeight(JavaFXClass.MAX_HEIGHT);

    primaryStage.setScene(new Scene(this.layout));

    Runnable stageResized =
        () -> this.stageResized(primaryStage.getWidth(), primaryStage.getHeight());
    ChangeListener<? super Number> widthHeightListener = (v, o, n) -> stageResized.run();
    primaryStage.widthProperty().addListener(widthHeightListener);
    primaryStage.heightProperty().addListener(widthHeightListener);

    primaryStage.show();
    primaryStage.centerOnScreen();
    stageResized.run();
  }
Exemplo n.º 2
0
  /** nastaví maximální šířku okna. */
  public ScreenBuilder setMaxWidth(double maxWidth) {
    stage.setMaxWidth(maxWidth);

    return this;
  }
  public BoardView(int noPlayers, final Stage primaryStage) {

    window = primaryStage;
    window.setTitle("Quoridor");
    window.setMaxHeight(1280);
    window.setMaxWidth(1280);
    window.setResizable(false);

    BorderPane border = new BorderPane();

    infoPane = new FlowPane();
    infoPane.setPadding(new Insets(10));
    infoPane.setHgap(40);
    infoPane.setVgap(10);
    infoPane.setOrientation(Orientation.HORIZONTAL);

    bottomPane = new HBox();
    bottomPane.setSpacing(345);

    gameGrid = new GridPane();
    gameGrid.setPadding(new Insets(4));
    gameGrid.setId("gamegrid");

    border.setTop(infoPane);
    border.setCenter(gameGrid);

    playerPositionButtons = new PlayerPositionButton[9][9];
    wallPositionButtons = new WallPositionButton[9][8];
    horizontalWalls = new Pane[9][9];
    verticalWalls = new Pane[9][9];

    column = 0;
    row = 0;

    chooseVertical = new Button();
    chooseVertical.setPrefSize(100, 100);
    chooseVertical.setId("vWallBtn");

    Button home = new Button();
    home.setPrefSize(100, 100);
    home.setId("home");
    home.setOnAction(e -> confirmBox());

    bottomPane.getChildren().addAll(chooseVertical, home);

    border.setBottom(bottomPane);
    border.setMargin(bottomPane, new Insets(40, 40, 20, 20));

    for (int y = 0; y < 8; y++) {
      createMoveLine(y);
      createWallLine(y);
    }

    createMoveLine(8);

    main = new Scene(border, 600, 768);
    main.getStylesheets().add("gameplay/viewJFX/" + stylesheet);
    buildPlayerLabels(noPlayers);
    window.setScene(main);
    window.show();
  }