Fix: buttons now change their size relative to screen size
This commit is contained in:
+12
-2
@@ -68,8 +68,18 @@ public class LobbyButtonGridManager {
|
|||||||
int buttonId = entry.getKey();
|
int buttonId = entry.getKey();
|
||||||
Button btn = new Button();
|
Button btn = new Button();
|
||||||
btn.setId("lobbyBtn-" + buttonId);
|
btn.setId("lobbyBtn-" + buttonId);
|
||||||
btn.setGraphic(
|
ImageView imageView = new ImageView(new Image(getClass().getResourceAsStream(BUTTON_IMAGE_PATH)));
|
||||||
new ImageView(new Image(getClass().getResourceAsStream(BUTTON_IMAGE_PATH))));
|
imageView.setPreserveRatio(true);
|
||||||
|
// Dynamische Breite: Bindung an die Zellengröße
|
||||||
|
imageView.fitWidthProperty().bind(gridPane.widthProperty().divide(COLS).subtract(20));
|
||||||
|
imageView.setSmooth(true);
|
||||||
|
btn.setGraphic(imageView);
|
||||||
|
btn.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
btn.setMaxHeight(Double.MAX_VALUE);
|
||||||
|
btn.setMinWidth(10);
|
||||||
|
btn.setMinHeight(10);
|
||||||
|
GridPane.setHgrow(btn, javafx.scene.layout.Priority.ALWAYS);
|
||||||
|
GridPane.setVgrow(btn, javafx.scene.layout.Priority.ALWAYS);
|
||||||
btn.setOnAction(
|
btn.setOnAction(
|
||||||
e -> {
|
e -> {
|
||||||
Integer lobbyId = translationManager.getLobbyIdForButton(buttonId);
|
Integer lobbyId = translationManager.getLobbyIdForButton(buttonId);
|
||||||
|
|||||||
Reference in New Issue
Block a user