diff --git a/src/main/java/graphics/ProductAdsThumb.java b/src/main/java/graphics/ProductAdsThumb.java index 4ae409a..81a3a97 100644 --- a/src/main/java/graphics/ProductAdsThumb.java +++ b/src/main/java/graphics/ProductAdsThumb.java @@ -37,15 +37,19 @@ public void setProduct(Product product) { } public void initialize () { - Image productImage = product.getProductImage(); - image.setImage(productImage); - name.setText(product.getName()); - price.setText(String.valueOf(product.getPrice())); - if (product.hasOff()) { - offImage.setImage(new Image(Paths.get("src/main/resources/images/offImage.png").toUri().toString())); - offLabel.setText(getOffPercentage() + "% OFF!"); - offLabel.setVisible(true); - offImage.setVisible(true); + if (product != null) { + Image productImage = product.getProductImage(); + image.setImage(productImage); + name.setText(product.getName()); + price.setText(String.valueOf(product.getPrice())); + if (product.hasOff()) { + offImage.setImage(new Image(Paths.get("src/main/resources/images/offImage.png").toUri().toString())); + offLabel.setText(getOffPercentage() + "% OFF!"); + offLabel.setVisible(true); + offImage.setVisible(true); + } + } else { + image.setImage(new Image("src/main/resources/images/shop-logo.png")); } } diff --git a/src/main/java/graphics/SlideShow.java b/src/main/java/graphics/SlideShow.java index fcc9426..7e5ca4e 100644 --- a/src/main/java/graphics/SlideShow.java +++ b/src/main/java/graphics/SlideShow.java @@ -51,6 +51,9 @@ public void handle(MouseEvent event) { } public void initialize() throws InterruptedException, IOException { + if (Database.getAllProductAds().size() == 0) { + addPage(null); + } for (Product product : Database.getAllProductAds()) { addPage(new ProductAdsThumb(product)); }