Java Code Examples for javafx.scene.layout.HBox#setClip()

The following examples show how to use javafx.scene.layout.HBox#setClip() . 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 vote down vote up
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 vote down vote up
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);

    }