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

[hidpi] JOptionPane-Icons only partially visible when using Windows 10 L&F

    Details

    • Subcomponent:
    • Resolved In Build:
      b127
    • CPU:
      generic
    • OS:
      windows_10

      Description

      The icons (error, info, question) are only partially visible when showing a JOptionPane under Windows 10, HiDPI, Windows Look and Feel. Only the top left quarter is visible (see screenshot).

      Code to reproduce the issue:
      ==================================
      import javax.swing.*;
      import java.awt.*;

      public class JOptionPaneBadIcon {

          public static void main(String[] args) {
              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
                  e.printStackTrace();
              }

              SwingUtilities.invokeLater(() -> {
                  final JFrame frame = new JFrame();
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setLayout(new BorderLayout());
                  final JButton open = new JButton("Open");
                  frame.add(open);
                  open.addActionListener(l -> {
      JOptionPane.showMessageDialog(null, "Some odd message.", "Title", JOptionPane.ERROR_MESSAGE);
                  });
                  frame.setBounds(200, 200, 200, 200);
                  frame.setVisible(true);
              });
          }
      }
      ==================================

      I was not able to reproduce the failure on Windows 7 or Windows 8.1. The problem is caused by the fact that apparently starting with Windows 10, Windows delivers larger icons when in HiDPI mode. The code asking for those icons in ShellFolder2.cpp (Java_sun_awt_shell_Win32ShellFolder2_getIconBits) does not check at all what the OS returns, but is given hardcoded sizes. Therefore the icons are cropped as seen in the screenshot.

      Solution: Change the method so that it takes actual icon sizes into account.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hschreiber Hendrik Schreiber
                Reporter:
                hschreiber Hendrik Schreiber
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: