JDK-8236953 : [macos] JavaFX SwingNode is not rendered on macOS
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 11,13,14
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • Submitted: 2020-01-11
  • Updated: 2022-02-03
  • Resolved: 2020-01-16
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 11 JDK 13 JDK 14 JDK 15
11.0.8-oracleFixed 13.0.4Fixed 14 b33Fixed 15Fixed
Related Reports
Relates :  
Description
To reproduce this, run the attached test program using a recent version of openjfx (e.g., 13.0.1 or 14-ea) with JDK 13 or later on macOS. It should render a Swing JLabel at the top of the window, a Swing Button in the middle, and an FX Button at the bottom. Only the FX button shows up.

This works correctly using the same version of FX, but running it with JDK 12, so it is a regression in the JDK introduced in JDK 13.

The test program attached to JDK-8193103 also reproduces the bug
Comments
Fix request (13u): The original change applies cleanly, tested with tier1. The HelloSwingNode sample works fine with the patch.
04-06-2020

Fix request (11u) -- will label after testing completed. I would like to downport this for parity with 11.0.8-oracle. Applies clean.
17-03-2020

URL: https://hg.openjdk.java.net/jdk/jdk14/rev/6825c74baa36 User: serb Date: 2020-01-16 04:36:12 +0000
16-01-2020

This issue is introduced due to change in JDK-8144125. The fix, it seems, is to issue the RESIZE and MOVED event only once when programmatically moving or resizing a component. I do not see any ComponentEvent handler in SwingNode, unlike JFXPanel, not sure how it was handled till this time, probably in Node. Probably we do the following fix: diff -r 1bcfc908724e src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java --- a/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Fri Jan 10 13:08:18 2020 +0000 +++ b/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Mon Jan 13 14:17:15 2020 +0530 @@ -1119,11 +1119,20 @@ */ protected final void handleMove(final int x, final int y, final boolean updateTarget) { + boolean fx = false; + if (System.getProperty("javafx.version") != null && + Thread.currentThread().getThreadGroup().getParent() != null) { + fx = true; + } if (updateTarget) { AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y); + if (!fx) + postEvent(new ComponentEvent(getTarget(), + ComponentEvent.COMPONENT_MOVED)); + } + if (fx) postEvent(new ComponentEvent(getTarget(), ComponentEvent.COMPONENT_MOVED)); - } } /** @@ -1143,11 +1152,20 @@ } getLWGC().destroyBackBuffer(oldBB); + boolean fx = false; + if (System.getProperty("javafx.version") != null && + Thread.currentThread().getThreadGroup().getParent() != null) { + fx = true; + } if (updateTarget) { AWTAccessor.getComponentAccessor().setSize(getTarget(), w, h); + if (!fx) + postEvent(new ComponentEvent(getTarget(), + ComponentEvent.COMPONENT_RESIZED)); + } + if (fx) postEvent(new ComponentEvent(getTarget(), ComponentEvent.COMPONENT_RESIZED)); - } } With this jdk regression testcase and this fx test case, both pass.
13-01-2020

nice to fix in JDK 14
11-01-2020

It's possible that this is a 2D rendering bug and not a Swing bug. I see black rectangles where the Swing button and label should be some of time time (usually as I'm resizing it, but a couple times on start up).
11-01-2020