diff --git a/src/main/java/ApProject_OnlineShop/GUI/productPageRelated/AllProductsPage.java b/src/main/java/ApProject_OnlineShop/GUI/productPageRelated/AllProductsPage.java index 515d4ce1..ffb1bad4 100644 --- a/src/main/java/ApProject_OnlineShop/GUI/productPageRelated/AllProductsPage.java +++ b/src/main/java/ApProject_OnlineShop/GUI/productPageRelated/AllProductsPage.java @@ -164,13 +164,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) { public void setProducts() { int num = 0; int row = 0; - if ((MainController.getInstance().getAllProductsController().getGoods().size() % 3 != 0)) { - if ((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 1) * 250) > 1067) { - mainGridPane.setPrefHeight((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 1) * 250) + 133); - } - } else { - mainGridPane.setPrefHeight((((MainController.getInstance().getAllProductsController().getGoods().size() / 3)) * 250) + 133); - } for (Long productId : MainController.getInstance().getAllProductsController().getGoods()) { if (MainController.getInstance().getAllProductsController().isInOff(productId)) { VBox vbox = new ProductBriefSummery().offProductBriefSummery(productId); @@ -189,6 +182,17 @@ public void setProducts() { if (num % 3 == 0) row++; } + if (MainController.getInstance().getAllProductsController().getGoods().size() == 0) + return; + if ((MainController.getInstance().getAllProductsController().getGoods().size() % 3 != 0)) { + if ((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 1) * 250) > 1067) { + mainGridPane.setPrefHeight((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 1) * 250) + 133); + } + } else { + if ((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 0) * 250) > 1067) { + mainGridPane.setPrefHeight((((MainController.getInstance().getAllProductsController().getGoods().size() / 3) + 0) * 250) + 133); + } + } } public void handleSorts() {