RFR: 8170794: [macosx] Error when using setDesktopManager on a JDesktopPane on MacOS X with Look and Feel Aqua
Prasanta Sadhukhan
psadhukhan at openjdk.org
Thu Jul 7 12:13:09 UTC 2022
When we call JDesktopPane.setDesktopManager(new DefaultDesktopManager()) and try to iconify an internalframe, it results in NPE
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.RepaintManager.getVolatileOffscreenBuffer(RepaintManager.java:1030)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1489)
at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
at javax.swing.JComponent.paint(JComponent.java:1042)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at com.apple.laf.AquaInternalFrameDockIconUI$ScaledImageLabel.updateIcon(AquaInternalFrameDockIconUI.java:193)
at com.apple.laf.AquaInternalFrameDockIconUI$ScaledImageLabel.paint(AquaInternalFrameDockIconUI.java:204)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
it seems the getVolatileOffscreenBuffer() is called with JRootPane component for AquaLookAndFeel because of which
SwingUtilities.getWindowAncestor(JRootPane) returns null causing NPE.
Fixed by adding a null check. The JInternalFrame can be successfully iconized now after setting DesktopManager.
-------------
Commit messages:
- Fix
- Fix
- 8170794: [macosx] Error when using setDesktopManager on a JDesktopPane on MacOS X with Look and Feel Aqua
Changes: https://git.openjdk.org/jdk/pull/9408/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9408&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8170794
Stats: 106 lines in 2 files changed: 105 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/9408.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/9408/head:pull/9408
PR: https://git.openjdk.org/jdk/pull/9408
More information about the client-libs-dev
mailing list