From 465798ee3df3f906058752b5da6dea4f3c95ea09 Mon Sep 17 00:00:00 2001 From: geroyche Date: Mon, 20 Feb 2023 16:45:52 +0100 Subject: [PATCH] catch npe --- .../java/com/formdev/flatlaf/util/ScaledImageIcon.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ScaledImageIcon.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ScaledImageIcon.java index e510382d..8b0d757f 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ScaledImageIcon.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/ScaledImageIcon.java @@ -100,8 +100,13 @@ debug*/ Image image = getResolutionVariant( destImageWidth, destImageHeight ); // size of image - int imageWidth = image.getWidth( null ); - int imageHeight = image.getHeight( null ); + int imageWidth = -1; + int imageHeight = -1; + + if (image != null) { + imageWidth = image.getWidth( null ); + imageHeight = image.getHeight( null ); + } // paint red rectangle if image has invalid size (e.g. not found) if( imageWidth < 0 || imageHeight < 0 ) {