Java Code Examples for javafx.scene.layout.HBox#setMinSize()
The following examples show how to use
javafx.scene.layout.HBox#setMinSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Board.java From util4j with Apache License 2.0 | 6 votes |
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); }
Example 2
Source File: Board.java From Game2048FX with GNU General Public License v3.0 | 5 votes |
private void createGrid() { for (int i = 0; i < gridOperator.getGridSize(); i++) { for (int j = 0; j < gridOperator.getGridSize(); j++) { gridGroup.getChildren().add(createCell(i, j)); } } 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); }
Example 3
Source File: FindGroupItem.java From oim-fx with MIT License | 4 votes |
private void initComponent() { headImageView.setFitHeight(60); headImageView.setFitWidth(60); headClip.setArcHeight(60); headClip.setArcWidth(60); headClip.setWidth(60); headClip.setHeight(60); headImagePane.setClip(headClip); headImagePane.getChildren().add(headImageView); headImagePane.setStyle("-fx-background-color:rgba(255, 255, 255, 0.9)"); pane.getStyleClass().add("head-common-image-pane"); pane.getChildren().add(headImagePane); pane.setPrefWidth(60); pane.setPrefHeight(60); pane.setLayoutX(2); pane.setLayoutY(2); headImageShowPane.getChildren().add(pane); headRootPane.setTop(getGapNode(3)); headRootPane.setRight(getGapNode(5)); headRootPane.setLeft(getGapNode(5)); headRootPane.setBottom(getGapNode(3)); headRootPane.setCenter(headImageShowPane); headBaseRootPane.getChildren().add(headRootPane); headBaseRootPane.setPrefWidth(75); headBaseRootPane.setMinWidth(75); textBaseRootPane.getChildren().add(getGapNode(12)); textBaseRootPane.getChildren().add(infoPane); textBaseRootPane.getChildren().add(textRootPane); // textBaseRootPane.getChildren().add(addButton); // textBaseRootPane.getChildren().add(getGapNode(5)); infoPane.getChildren().add(nameLabel); textRootPane.getChildren().add(infoTextLabel); nameLabel.setStyle("-fx-text-fill:#000000;-fx-font-size:15px;"); infoTextLabel.setStyle("-fx-text-fill:#888888;-fx-font-size:14px;"); HBox hBox = new HBox(); hBox.getChildren().add(headBaseRootPane); hBox.getChildren().add(textBaseRootPane); textArea.setEditable(false); textArea.setBorder(Border.EMPTY); textArea.getStyleClass().clear(); VBox vBox = new VBox(); vBox.setPadding(new Insets(5, 5, 5, 5)); vBox.getChildren().add(hBox); vBox.getChildren().add(textArea); HBox iconBox = new HBox(); iconBox.getStyleClass().add("find-add-icon"); iconBox.setMinSize(14, 15); addButton.setGraphic(iconBox); addButton.getStyleClass().add("find-add-button"); addButton.setText("加群"); HBox bottomBox = new HBox(); bottomBox.setAlignment(Pos.BASELINE_RIGHT); bottomBox.setStyle("-fx-background-color:#e6e6e6"); bottomBox.setPadding(new Insets(5, 10, 5, 10)); bottomBox.getChildren().add(addButton); this.setStyle("-fx-border-color:#e6e6e6;-fx-border-width: 1px;"); this.setCenter(vBox); this.setBottom(bottomBox); }
Example 4
Source File: FindUserItem.java From oim-fx with MIT License | 4 votes |
private void initComponent() { headImageView.setFitHeight(60); headImageView.setFitWidth(60); headClip.setArcHeight(60); headClip.setArcWidth(60); headClip.setWidth(60); headClip.setHeight(60); headImagePane.setClip(headClip); headImagePane.getChildren().add(headImageView); headImagePane.setStyle("-fx-background-color:rgba(255, 255, 255, 0.9)"); pane.getStyleClass().add("head-common-image-pane"); pane.getChildren().add(headImagePane); pane.setPrefWidth(60); pane.setPrefHeight(60); pane.setLayoutX(2); pane.setLayoutY(2); headImageShowPane.getChildren().add(pane); headRootPane.setTop(getGapNode(3)); headRootPane.setRight(getGapNode(5)); headRootPane.setLeft(getGapNode(5)); headRootPane.setBottom(getGapNode(3)); headRootPane.setCenter(headImageShowPane); headBaseRootPane.getChildren().add(headRootPane); headBaseRootPane.setPrefWidth(75); headBaseRootPane.setMinWidth(75); HBox iconBox = new HBox(); iconBox.getStyleClass().add("find-add-icon"); iconBox.setMinSize(14, 15); addButton.setGraphic(iconBox); addButton.getStyleClass().add("find-add-button"); addButton.setText("好友"); textBaseRootPane.getChildren().add(getGapNode(12)); textBaseRootPane.getChildren().add(infoPane); textBaseRootPane.getChildren().add(textRootPane); textBaseRootPane.getChildren().add(addButton); // textBaseRootPane.getChildren().add(getGapNode(5)); infoPane.getChildren().add(nicknameLabel); textRootPane.getChildren().add(textLabel); nicknameLabel.setStyle("-fx-text-fill:#000000;-fx-font-size:14px;"); textLabel.setStyle("-fx-text-fill:#888888;-fx-font-size:12px;"); textLabel.setWrapText(true); this.getChildren().add(headBaseRootPane); this.getChildren().add(textBaseRootPane); }
Example 5
Source File: Board.java From util4j with Apache License 2.0 | 4 votes |
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); }
Example 6
Source File: Board.java From Game2048FX with GNU General Public License v3.0 | 4 votes |
private void createScore() { Label lblTitle = new Label("2048"); 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("SCORE"); lblTit.getStyleClass().addAll("game-label", "game-titScore"); lblScore.getStyleClass().addAll("game-label", "game-score"); lblScore.textProperty().bind(gameScore.asString()); vScore.getChildren().addAll(lblTit, lblScore); VBox vRecord = new VBox(-5); vRecord.setAlignment(Pos.CENTER); vRecord.getStyleClass().add("game-vbox"); Label lblTitBest = new Label("BEST"); lblTitBest.getStyleClass().addAll("game-label", "game-titScore"); lblBest.getStyleClass().addAll("game-label", "game-score"); lblBest.textProperty().bind(gameBest.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_CENTER); lblMode.getStyleClass().addAll("game-label", "game-time"); lblTime.getStyleClass().addAll("game-label", "game-time"); lblTime.textProperty().bind(clock); HBox hGap = new HBox(); HBox.setHgrow(hGap, Priority.ALWAYS); 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().addAll(lblMode, hGap, 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); }