JDK-8255880 : UI of Swing components is not redrawn after their internal state changed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7,8,11,15,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,solaris
  • Submitted: 2020-11-04
  • Updated: 2021-05-12
  • Resolved: 2020-12-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 11 JDK 13 JDK 15 JDK 16 JDK 17 JDK 7 JDK 8 Other
11.0.11-oracleFixed 13.0.8Fixed 15.0.4Fixed 16Fixed 17 b02Fixed 7u291Fixed 8u291Fixed openjdk8u292Fixed
x64 Oracle Solaris 11.4 OS with GNOME 3, x64 Linux OS with GNOME 3.

If "javax.swing.JFrame" window is in minimized state and during this time the application changes internal states of Swing components contained in this window, for example through such methods as "javax.swing.JButton.setText(String)", "javax.swing.JLabel.setIcon(Icon)" etc., then after the user makes the window visible by returning it back to a normal state, the UI of Swing components does not reflect the latest changes in their internal states, for example a text on "JButton" instance is not updated, a new image is not drawn in "JLabel" instance.

1. Compile and run the attached to this bug test case "ChangingSwingCompsViewTestV2.java".
2. Click "Start Test Iteration" button and immediately within 10 seconds minimize the window of the test case application by doing right click on any place of the title bar of the application window and by selecting 'Minimize' option in the system popup menu.
3. Wait for 10 seconds and return the minimized window back to a normal state.

The bug is reproduced, if the UI components are not updated with correct data. On each test iteration the text on all the tested UI components will contain the new sub-strings, for example "AAA" will be changed to "BBB", on next test iteration "BBB" sub-strings will be changed to "CCC".
Fix request (13u): the same as 15u, clean and no regressions detected.

Fix request (15u): applies seamlessly. New test does fail before patch and pass after; automated swing tests OK.

Fix Request (8u) I would like to backport this patch to openjdk8u for parity with Oracle 8u291. The original patch applies cleanly and new test passes.

Fix Request Should get backported for parity with 11.0.11-oracle. Applies cleanly.

Changeset: 87644a2b Author: Anton Litvinov <alitvinov@openjdk.org> Date: 2020-12-16 19:48:07 +0000 URL: https://git.openjdk.java.net/jdk/commit/87644a2b

Changeset: e8c40baf Author: Anton Litvinov <alitvinov@openjdk.org> Date: 2020-12-14 14:36:15 +0000 URL: https://git.openjdk.java.net/jdk/commit/e8c40baf

THE ROOT CAUSE OF THE BUG: It was defined that changes in states of Swing components do not lead to repaint of UI of "javax.swing.JFrame" instance, while the "JFrame" instance is in "java.awt.Frame.ICONIFIED" state, because the method "javax.swing.RepaintManager.addDirtyRegion0(Container, int, int, int, int)" explicitly prevents marking regions of "java.awt.Container" as dirty, if the "Container" is inside "java.awt.Frame" which is in "Frame.ICONIFIED" state. This behavior is correct and was implemented by the fix for the bug JDK-4665214. But JDK code specific to implementation for Linux OS does not initiate repaint of the frame on notification of change of its state from "Frame.ICONIFIED" to other states, as it is done for example in macOS specific method "sun.lwawt.LWWindowPeer.notifyIconify(boolean)" by the next code block. 674 if (!iconify) { 675 repaintPeer(); 676 } THE SUGGESTED SOLUTION: The suggested solution is to repaint "XFramePeer" instance in the method "handlePropertyNotify(XEvent)" from the file "src/java.desktop/unix/classes/sun/awt/X11/XFramePeer.java" by calling "XFramePeer.repaint()", when its state changed from "Frame.ICONIFIED" to other frame state.

The test case "ChangingSwingCompsViewTestV2.java" was attached to the issue. The bug was reproduced on: - x64 Oracle Solaris 11.4 OS with GNOME 3 using JDK 8u271 b09, JDK 7u281 b06. - x64 Linux OS with GNOME 3 using JDK 16+25, JDK 11.0.9+7, JDK 8u271 b09, JDK 8 b132, JDK 7u281 b06, JDK 7u7 b10. These test results demonstrate that this bug affects JDK both for Oracle Solaris OS and for Linux OS. Also during experiments it was proven that the bug is reproducible and in GNOME 3 and in GNOME 3 Classic. THE WORKAROUNDS: It is proven that resizing the affected Java application's window or calling "java.awt.Window.repaint()" method on the Java object corresponding to this window, allows to redraw the UI of all components in the window and to resolve the bug.