我绑定Tile Property
以使HomeTabCell
动态调整其宽度和高度值。但是HomeTabCell
的宽度和高度保持不变。
这是一种让它工作的方法,还是我应该使用GridPane
?
for (int i = 0; i < room.getMaxPlayers(); i++) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/HomeTabCell.fxml"));
tilePane.getChildren().add(fxmlLoader.load());
tilePane.prefTileWidthProperty().bind(centerRoomHBox.widthProperty().divide(2).subtract(3));
tilePane.prefTileHeightProperty().bind(centerRoomHBox.heightProperty().divide(6 / 2));
HomeTabCell box = (HomeTabCell) fxmlLoader.getController();
box.setInfo(null, room.getMaxPlayers());
} catch (IOException ex) {
bugsnag.notify(ex);
}
}
答案 0 :(得分:0)
我必须从anchorPane
HomeTabCell
进行public
,然后绑定宽度和高度值。
for (int i = 0; i < room.getMaxPlayers(); i++) {
try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/HomeTabCell.fxml"));
tilePane.getChildren().add(fxmlLoader.load());
tilePane.prefTileWidthProperty().bind(centerRoomHBox.widthProperty().divide(2).subtract(3));
tilePane.prefTileHeightProperty().bind(centerRoomHBox.heightProperty().divide(6 / 2));
HomeTabCell box = (HomeTabCell) fxmlLoader.getController();
box.anchorPane.prefWidthProperty().bind(centerRoomHBox.widthProperty().divide(2).subtract(3));
box.anchorPane.prefHeightProperty().bind(centerRoomHBox.heightProperty().divide(6 / 2));
box.setInfo(null, room.getMaxPlayers());
} catch (IOException ex) {
bugsnag.notify(ex);
}
}