JDK-8151385 : [hidpi] JOptionPane-Icons only partially visible when using Windows 10 L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u74,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • CPU: generic
  • Submitted: 2016-03-07
  • Updated: 2016-07-14
  • Resolved: 2016-06-14
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 9
9 b127Fixed
Related Reports
Relates :  
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.

Comments
Patch sent to http://mail.openjdk.java.net/pipermail/awt-dev/2016-March/010777.html
08-03-2016

A fix for this will also help JDK-8149453, as the icons can be loaded in the correct size.
08-03-2016