JDK-8282526 : Default icon is not painted properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 17,18,19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2022-02-28
  • Updated: 2024-07-09
  • Resolved: 2022-07-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 20
17.0.13-oracleFixed 20 b07Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10, jdk-19 and jdk-17

A DESCRIPTION OF THE PROBLEM :
I used the javax.swing.filechooser.FileSystemView.getSystemIcon(File) method to get the icon from system. When the file has the default icon, the method returns an icon that looks cropped.
With Java 8 everything is ok. I reproduced the problem with Java 17 and Java 19
I attached a sample in the "Source code for an executable test case" section.

REGRESSION : Last worked in version 8u321

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create the "D:\\toDelete\\abc.bla" file into your system. (it has to have an unknown extension)
2. Run the code from the "Source code for an executable test case" section with Java 19.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The icon from the second button should be well painted.
ACTUAL -
The icon from the second button is cropped on the north side.

---------- BEGIN SOURCE ----------
import java.io.File;
import javax.swing.Box;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.filechooser.FileSystemView;
public class SwingDemo {
  
   public static void main(String[] args) {
      JButton button1 = new JButton("text");
      Icon icon =  FileSystemView.getFileSystemView().getSystemIcon(new File("D:\\toDelete\\abc.bla"));
      JButton button2 = new JButton(icon);
      
      Box box = Box.createVerticalBox();
      box.add(button1);
      box.add(button2);
      JFrame frame = new JFrame();
      frame.add(box);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationByPlatform(true);
      frame.setSize(500, 300);
      frame.setVisible(true);
   }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
I didn't find a workaround.

FREQUENCY : always



Comments
Explanation for "parity with 17.0.13-oracle": This issue has no backport links, but the comment from Alexey Ivanov below indicates that it is probably bundled with the other related issues without separate backport issue. Either way, I'd like to backport the 3 ones he has mentioned.
06-06-2024

[jdk17u-fix-request] Approval Request from Martin Should get backported for parity with 17.0.13-oracle. Applies cleanly (except Copyright year update) and tier1-4 have passed.
06-06-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/2538 Date: 2024-06-05 13:37:11 +0000
05-06-2024

This fix and subsequent fixes reveals two additional problems: JDK-8293862 and JDK-8320692. Backporting shouldn't start until JDK-8320692 is resolved to avoid adding known regressions into the code base. The backport to 17u should combine all the three fixes to ensure the regressions aren't introduced; alternatively, the fixes should be integrated in quick succession.
08-01-2024

Changeset: 6c8d0e61 Author: Alexander Zuev <kizune@openjdk.org> Date: 2022-07-18 20:33:19 +0000 URL: https://git.openjdk.org/jdk/commit/6c8d0e617ff59eee1313589b10edbf5830774db5
18-07-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7805 Date: 2022-03-13 21:06:24 +0000
13-03-2022

The main reason for this is that with the new code the image that is returned for default file is a high resolution 32x32 image that is being painted within the 16x16 icon. Because by default the interpolation mode is set no nearest neighbor that creates a visual artifacts. The idea of the fix is to detect the situation where interpolation is required and temporarily set rendering hint to enable bicubic interpolation.
13-03-2022

Checked with attached testcase in Windows 10, cropping of icon was not observed<attached Screenshot for reference> Mail to submitter: ============== Please share the screen shot of the issue.
08-03-2022

Custom icons is not painted well, (top border line and left border line). Observed when display scale is changed in JDK 17, 18ea, 19ea.<attached screenshot> The issue is not observed in JDK 8 and 11, Test Result ========= 8u321: Pass 11.0.14: Pass 17.0.2: Fail 18ea36: Fail 19ea11: Fail
08-03-2022

Additional Information from Submitter: ============================ I created a screenshot with the differences between Java 8 and Java 19<attached screenshot.png> As you can observe, the horizontal line from the top of the icon is not painted.
07-03-2022