-
Notifications
You must be signed in to change notification settings - Fork 110
NullPointerException in CheckBoxMenuItemIcon.getIconWidth() #86
Comments
I'm not seeing the crash with the latest 8.1.00dev build on my Mac. It might take me some time to test on a Windows box since that's not my dev environment. |
No crash running 8.0.02 as well on Mac with Java 1.8.0_112. |
On Windows using Java 1.8.0_131 also doesn't crash. I found this commit in the OpenJDK repo which is referenced in the bugfixes of 1.8.0_152 which might be related: It looks like a change listener in BasicMenuItemUI is now updating the checkIcon when setHorizontalTextPosition is called. |
Confirming crash in Java 1.8.0_161 on my Mac. Will be addressed shortly in 8.1.00dev branch. |
That is actually a pretty bad change of behavior. The UI delegate gets the chance to install its own visual decorations in the regular installDefaults() method. But then, the basic UI delegate incorrectly replaces the checkIcon set earlier with the version taken from the UIManager global table - a version that is not connected to the specific menuItem (which, in Substance's case, is needed for proper animations and size-aware painting). There is the option to "install" a check icon factory on the UIManager, but the matching MenuItemCheckIconFactory class is in sun.swing package, only exposed to the Vista look and feel. What a mess this is. I'll need to find the way to essentially "roll back" the check icon override. |
Version of Substance
8.0.02
Version of Java
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
Version of OS
Microsoft Windows [Version 10.0.16299.371]
The issue you're experiencing (expected vs actual, screenshot, stack trace etc)
When a JMenu contains both regular JItems, and a JCheckBoxMenuItem, all with a custom icon, and the user opens the menu an NPE occurs:
Code triggering the problem (created by expanding the Walkthrough example):
I've found a workaround that I commented in the code. However, that should not be necessary.
Icon resource used by the sample:
The text was updated successfully, but these errors were encountered: