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)

This commit is contained in:
Karl Tauber
2023-08-07 19:35:04 +02:00
parent afaa2c8c78
commit 4b4990635d
2 changed files with 8 additions and 1 deletions

View File

@@ -61,6 +61,9 @@ FlatLaf Change Log
listener on that formatted text field. (issue #698) listener on that formatted text field. (issue #698)
- PopupMenu: Make sure that popup menu does not overlap any operating system - PopupMenu: Make sure that popup menu does not overlap any operating system
task bar. (issue #701) 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 #### Incompatibilities

View File

@@ -53,6 +53,7 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.metal.MetalFileChooserUI; import javax.swing.plaf.metal.MetalFileChooserUI;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.icons.FlatFileViewDirectoryIcon;
import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.LoggingFacade;
import com.formdev.flatlaf.util.ScaledImageIcon; import com.formdev.flatlaf.util.ScaledImageIcon;
import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.SystemInfo;
@@ -346,7 +347,7 @@ public class FlatFileChooserUI
fileView.clearIconCache(); fileView.clearIconCache();
} }
private boolean doNotUseSystemIcons() { private static boolean doNotUseSystemIcons() {
// Java 17 32bit craches on Windows when using system icons // Java 17 32bit craches on Windows when using system icons
// fixed in Java 18+ (see https://bugs.openjdk.java.net/browse/JDK-8277299) // fixed in Java 18+ (see https://bugs.openjdk.java.net/browse/JDK-8277299)
return SystemInfo.isWindows && return SystemInfo.isWindows &&
@@ -526,6 +527,9 @@ public class FlatFileChooserUI
return icon; return icon;
} }
if( doNotUseSystemIcons() )
return new FlatFileViewDirectoryIcon();
// Java 17+ supports getting larger system icons // Java 17+ supports getting larger system icons
try { try {
if( SystemInfo.isJava_17_orLater ) { if( SystemInfo.isJava_17_orLater ) {