Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8282526

Default icon is not painted properly

XMLWordPrintable

    • 17
    • b07
    • x86_64
    • windows_10

        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


          1. Capture_scale100.PNG
            Capture_scale100.PNG
            5 kB
          2. Capture_scale125.PNG
            Capture_scale125.PNG
            7 kB
          3. Capture_scale150.PNG
            Capture_scale150.PNG
            8 kB
          4. Capture.PNG
            Capture.PNG
            31 kB
          5. screenshot.png
            screenshot.png
            6 kB
          6. SwingDemo.java
            0.8 kB

              kizune Alexander Zuev
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: