From e9a28de2c0242820146e4dd81c04161833778d03 Mon Sep 17 00:00:00 2001 From: morabba <292.arma@gmail.com> Date: Sat, 27 Jun 2020 01:44:17 +0430 Subject: [PATCH] come on! --- src/main/java/graphics/ProductAdsThumb.java | 22 ++++++++++++--------- src/main/java/graphics/SlideShow.java | 3 +++ 2 files changed, 16 insertions(+), 9 deletions(-) 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)); }