From 4b4990635d2286a23b6b98c029821c0a149efdee Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 7 Aug 2023 19:35:04 +0200 Subject: [PATCH] FileChooser: Fixed crash on Windows with Java 17 to 17.0.2 32-bit. Java 17 64-bit is not affected. (regression since FlatLaf 2.3; PR #522, see also issue #403) --- CHANGELOG.md | 3 +++ .../main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9af7f08..0bdc960b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,9 @@ FlatLaf Change Log listener on that formatted text field. (issue #698) - PopupMenu: Make sure that popup menu does not overlap any operating system task bar. (issue #701) +- FileChooser: Fixed crash on Windows with Java 17 to 17.0.2 32-bit. Java 17 + 64-bit is not affected. (regression since FlatLaf 2.3; PR #522, see also issue + #403) #### Incompatibilities diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java index 96fd8c2c..0450c1c5 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFileChooserUI.java @@ -53,6 +53,7 @@ import javax.swing.plaf.ComponentUI; import javax.swing.plaf.metal.MetalFileChooserUI; import javax.swing.table.TableCellRenderer; import com.formdev.flatlaf.FlatClientProperties; +import com.formdev.flatlaf.icons.FlatFileViewDirectoryIcon; import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.ScaledImageIcon; import com.formdev.flatlaf.util.SystemInfo; @@ -346,7 +347,7 @@ public class FlatFileChooserUI fileView.clearIconCache(); } - private boolean doNotUseSystemIcons() { + private static boolean doNotUseSystemIcons() { // Java 17 32bit craches on Windows when using system icons // fixed in Java 18+ (see https://bugs.openjdk.java.net/browse/JDK-8277299) return SystemInfo.isWindows && @@ -526,6 +527,9 @@ public class FlatFileChooserUI return icon; } + if( doNotUseSystemIcons() ) + return new FlatFileViewDirectoryIcon(); + // Java 17+ supports getting larger system icons try { if( SystemInfo.isJava_17_orLater ) {