JDK-8031573 : [macosx] Checkmarks of JCheckBoxMenuItems aren't rendered in high resolution on Retina
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7,8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2014-01-13
  • Updated: 2017-05-24
  • Resolved: 2014-03-04
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 8 JDK 9 Other
8u20 b05Fixed 9Fixed openjdk7uFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b121)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b63, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin mankell 13.0.2 Darwin Kernel Version 13.0.2: Sun Sep 29 19:38:57 PDT 2013; root:xnu-2422.75.4~1/RELEASE_X86_64 x86_64

EXTRA RELEVANT SYSTEM CONFIGURATION :
Retina display

A DESCRIPTION OF THE PROBLEM :
Checkmarks of JCheckBoxMenuItems aren't rendered in high res on Retina displays.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a JFrame with a menu and a selected JCheckBoxMenuItem.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The checkmark should be rendered in high resolution/HiDPI, just like the all other components.
ACTUAL -
The checkmark is quite "pixely", rendered in low resolution.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

public class HiDPIJCheckBoxMenuItem {

    public static void main(String[] args) {
        final JFrame frame = new JFrame();
        final JMenuBar bar = new JMenuBar();
        final JMenu menu = new JMenu("Menu");
        final JCheckBoxMenuItem checkBoxMenuItem = new JCheckBoxMenuItem("JCheckBoxMenuItem");
        checkBoxMenuItem.setSelected(true);
        menu.add(checkBoxMenuItem);
        bar.add(menu);
        frame.setJMenuBar(bar);

        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                frame.setBounds(100, 100, 100, 100);
                frame.setVisible(true);
            }
        });
    }
}

---------- END SOURCE ----------
Comments
The solution is to manually retrieve image with double size and high resolution from NSImage.
13-02-2014

The same is for the JTabbedPane arrow icons
13-02-2014

It seems that NSMenuItemSelection is only template that should be processed before drawing. ------------------------ NSImage *image = [NSImage imageNamed:@"NSMenuItemSelection"]; NSLog(@"is template: %d", [image isTemplate]); // Output: is template: 1 ------------------------ See for example NSImageNameMenuOnStateTemplate https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html#//apple_ref/c/data/NSImageNameApplicationIcon ------------------------ Constants that end in the word "Template" name black and clear images that return YES for isTemplate. These images can be processed into variants appropriate for different situations. For example, these images can invert in a selected table view row. See setTemplate:: for more comments. These images are inappropriate for display without further processing, but NSCell and its subclasses will perform the processing. ------------------------
04-02-2014

No. The 1.6.0_29 shows the low-resolution JCheckBoxMenuItem icon on HiDPI display. The native Cocoa app shows that the NSMenuItemSelection image has only one image representation: ----------------- NSImage *image = [NSImage imageNamed:@"NSMenuItemSelection"]; NSImageRep *img = nil; NSArray *images = [image representations]; NSEnumerator *imageEnumerator = [images objectEnumerator]; NSLog(@"Image representations: %ld", [images count]); while ((img = [imageEnumerator nextObject]) != nil) { NSSize size = [img size]; NSLog(@"Image variant size[%f, %f]", size.width, size.height); } ----------------- The output is: WindowTest[60658:707] Image representations: 1 WindowTest[60658:707] Image variant size[11.000000, 11.000000]
04-02-2014

Is it work on jdk 6?
04-02-2014

NSImage://NSMenuItemSelection image does not contain high-resolution representation
04-02-2014

CImage.createImageFromName method should return MultiResolutionImage with all supported resolutions.
31-01-2014

Release team: Approved for deferral.
14-01-2014

JDK8: SQE OK to defer
13-01-2014

8-defer-request: Not a regression from jdk 7, not a jck, not a P1. Not a stopper for jdk 8.
13-01-2014

Sergey, if this is a P3 then please file defer request
13-01-2014