當前位置: 首頁>>代碼示例>>Java>>正文


Java HBox.setMinSize方法代碼示例

本文整理匯總了Java中javafx.scene.layout.HBox.setMinSize方法的典型用法代碼示例。如果您正苦於以下問題:Java HBox.setMinSize方法的具體用法?Java HBox.setMinSize怎麽用?Java HBox.setMinSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.layout.HBox的用法示例。


在下文中一共展示了HBox.setMinSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createGrid

import javafx.scene.layout.HBox; //導入方法依賴的package包/類
private void createGrid() {
    
    gridOperator.traverseGrid((i,j)->{
        gridGroup.getChildren().add(createCell(i, j));
        return 0;
    });

    gridGroup.getStyleClass().add("game-grid");
    gridGroup.setManaged(false);
    gridGroup.setLayoutX(BORDER_WIDTH);
    gridGroup.setLayoutY(BORDER_WIDTH);

    HBox hBottom = new HBox();
    hBottom.getStyleClass().add("game-backGrid");
    hBottom.setMinSize(gridWidth, gridWidth);
    hBottom.setPrefSize(gridWidth, gridWidth);
    hBottom.setMaxSize(gridWidth, gridWidth);
    
    // Clip hBottom to keep the dropshadow effects within the hBottom
    Rectangle rect = new Rectangle(gridWidth, gridWidth);
    hBottom.setClip(rect);
    hBottom.getChildren().add(gridGroup);
    
    vGame.getChildren().add(hBottom);
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:26,代碼來源:Board.java

示例2: createScore

import javafx.scene.layout.HBox; //導入方法依賴的package包/類
private void createScore() {
    Label lblTitle = new Label("fx2048");
    lblTitle.getStyleClass().addAll("game-label","game-title");
    Label lblSubtitle = new Label("FX");
    lblSubtitle.getStyleClass().addAll("game-label","game-subtitle");
    HBox hFill = new HBox();
    HBox.setHgrow(hFill, Priority.ALWAYS);
    hFill.setAlignment(Pos.CENTER);
    
    VBox vScores = new VBox();
    HBox hScores=new HBox(5);
    
    vScore.setAlignment(Pos.CENTER);
    vScore.getStyleClass().add("game-vbox");
    Label lblTit = new Label("分數");
    lblTit.getStyleClass().addAll("game-label","game-titScore");
    lblScore.getStyleClass().addAll("game-label","game-score");
    lblScore.textProperty().bind(gameScoreProperty.asString());
    vScore.getChildren().addAll(lblTit, lblScore);

    VBox vRecord = new VBox(-5);
    vRecord.setAlignment(Pos.CENTER);
    vRecord.getStyleClass().add("game-vbox");
    Label lblTitBest = new Label("最高分");
    lblTitBest.getStyleClass().addAll("game-label","game-titScore");
    lblBest.getStyleClass().addAll("game-label","game-score");
    lblBest.textProperty().bind(gameBestProperty.asString());
    vRecord.getChildren().addAll(lblTitBest, lblBest);
    hScores.getChildren().addAll(vScore,vRecord);
    VBox vFill = new VBox();
    VBox.setVgrow(vFill, Priority.ALWAYS);
    vScores.getChildren().addAll(hScores,vFill);
            
    hTop.getChildren().addAll(lblTitle, lblSubtitle, hFill,vScores);
    hTop.setMinSize(gridWidth, TOP_HEIGHT);
    hTop.setPrefSize(gridWidth, TOP_HEIGHT);
    hTop.setMaxSize(gridWidth, TOP_HEIGHT);

    vGame.getChildren().add(hTop);

    HBox hTime=new HBox();
    hTime.setMinSize(gridWidth, GAP_HEIGHT);
    hTime.setAlignment(Pos.BOTTOM_RIGHT);
    lblTime.getStyleClass().addAll("game-label","game-time");
    lblTime.textProperty().bind(clock);
    timer=new Timeline(new KeyFrame(Duration.ZERO, e->{
        clock.set(LocalTime.now().minusNanos(time.toNanoOfDay()).format(fmt));
    }),new KeyFrame(Duration.seconds(1)));
    timer.setCycleCount(Animation.INDEFINITE);
    hTime.getChildren().add(lblTime);
    
    vGame.getChildren().add(hTime);
    getChildren().add(vGame);
    
    lblPoints.getStyleClass().addAll("game-label","game-points");
    lblPoints.setAlignment(Pos.CENTER);
    lblPoints.setMinWidth(100);
    getChildren().add(lblPoints);
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:60,代碼來源:Board.java


注:本文中的javafx.scene.layout.HBox.setMinSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。