so i have a grid pane and an image view both of size 1000. They are both placed on the game grid pane at the coordinates (0,1). They should be overlapping perfectly, but the grid pane is wider then the image view. I have tested it already if I set the width of the scene to 1000 it cuts the window of perfectly where the image view ends so the problem is that the grid pane is for some reason wider then 1000. how can that be?
Here is my controller code:
gameGrdPn.getColumnConstraints().get(0).setMinWidth(1000);
gameGrdPn.getColumnConstraints().get(0).setPrefWidth(1000);
gameGrdPn.getColumnConstraints().get(0).setMaxWidth(1000);
gameGrdPn.getRowConstraints().get(1).setMinHeight(750);
gameGrdPn.getRowConstraints().get(1).setPrefHeight(750);
gameGrdPn.getRowConstraints().get(1).setMaxHeight(750);
playingFieldGrdPn.getColumnConstraints().removeAll(playingFieldGrdPn.getColumnConstraints());
playingFieldGrdPn.getRowConstraints().removeAll(playingFieldGrdPn.getRowConstraints());
playingFieldGrdPn.setMinSize(1000, 750);
playingFieldGrdPn.setMaxSize(1000, 750);
playingFieldGrdPn.setGridLinesVisible(true);
playingFieldGrdPn.setPadding(new Insets(0));
playingFieldGrdPn.prefWidthProperty().bind(gameGrdPn.getColumnConstraints().get(0).prefWidthProperty());
for (int x = 0; x < 1000; x++) {
ColumnConstraints col = new ColumnConstraints(1);
col.setHgrow(Priority.NEVER);
playingFieldGrdPn.getColumnConstraints().add(col);
}
for (int y = 0; y < 750; y++) {
RowConstraints row = new RowConstraints(1);
row.setVgrow(Priority.NEVER);
playingFieldGrdPn.getRowConstraints().add(row);
}
Image playingBoardImg = new Image(getClass().getResourceAsStream("HaseUndIgelPlayingBoard.png"));
ImageView playingBoardView = new ImageView(playingBoardImg);
gameGrdPn.add(playingBoardView, 0, 1, 1000, 750);
gameGrdPn.getChildren().get(4).toBack(); //sending imageView to back
and here is an image of the problem. Here the gaming pieces x cordinate is set to 1000. the grey area marks the grid pane.
I tried adjusting the size of the undelying panes to see what would happen, but that just resulted in the grid pane being cut off. Any kind help would be appreciated, since I am new to javafx!
Edit: I have figured out now that placing a gameStone expands the columnWidth. But how do I allow the picture to break the borders of its corresponding grid pane cell?
Here is the code i have so far:
for(int i = 0; i < 6; i++){
Image gamingPieceImg = new Image(getClass().getResourceAsStream("gamingPieces/gamingPiece-"+i+".png"));
ImageView gamingPieceView = new ImageView(gamingPieceImg);
gamingPieceView.setFitHeight(60);
gamingPieceView.setFitWidth(60);
GridPane.setColumnSpan(gamingPieceView, 1);
GridPane.setRowSpan(gamingPieceView, 1);
playingFieldGrdPn.add(gamingPieceView, 1000, 350);
}
Thanks in advance, Romina
