Details
-
Bug
-
Status: Resolved
-
P3
-
Resolution: Fixed
-
17, 18, 19
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
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
Attachments
Issue Links
- relates to
-
JDK-8289705 Handle the case where IExtractIconW::Extract returns S_FALSE
-
- Open
-
-
JDK-8289756 Do not always request 16x16 icon
-
- Open
-
-
JDK-8289707 Use LookupIconIdFromDirectoryEx to extract only available sizes of icon
-
- Open
-
-
JDK-8182043 Access to Windows Large Icons
-
- Resolved
-
-
JDK-8293862 javax/swing/JFileChooser/8046391/bug8046391.java failed with 'Cannot invoke "java.awt.Image.getWidth(java.awt.image.ImageObserver)" because "retVal" is null'
-
- Resolved
-
-
JDK-8289708 Extract only the requested icon size
-
- Open
-
(1 relates to, 2 links to)