当前位置: 首页>>代码示例>>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;未经允许,请勿转载。