JDK-7160604 : Using non-opaque windows - popups are initially not painted correctly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u31,7u3
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2012-04-11
  • Updated: 2014-10-15
  • Resolved: 2013-11-26
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 7 JDK 8
7u76Fixed 8 b119Fixed
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Windows 7 64bit

A DESCRIPTION OF THE PROBLEM :
Using the new non-opaque windows feature -
Popups (JPopupMenu/JComboBox) are initially not painted correctly if the invoking/parent Window is non-opaque using AWTUtilities#setWindowOpaque(window, false) or Window#setBackground(new Color(0, 0, 0, 0)).

This problem appears on JDK-6(1.6.0_31 x86/amd64) and JDK-7(1.7.0_3 x86/amd64).

note:
On JDK-6(1.6.0_31 x86/amd64) the initial paiting is correct but after moving the mouse one or more times over the popup, parts of the popup aren��'T painted any more, e.g. the border.

REGRESSION.  Last worked in version 7

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using the new non-opaque windows feature -
Popup-Menus are initially not painted correctly if the invoking/parent Window is non-opaque using AWTUtilities#setWindowOpaque(window, false) or Window#setBackground(new Color(0, 0, 0, 0)).

This problem appears on JDK-6(1.6.0_31 x86/amd64) and JDK-7(1.7.0_3 x86/amd64).

note:
On JDK-6(1.6.0_31 x86/amd64) the initial paiting is correct but after moving the mouse one or more times over the popup, parts of the popup aren��'T painted any more, e.g. the border.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
correct painted popups.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
package de.espirit.firstspirit.client.gui.util;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;


/**
 * $Date$
 *
 * @version $Revision$
 */
public class TestAwtUtilities {

	public static void main(final String[] args) {
		// Using non-opaque windows -
		// Popup-Menus are initially not painted correctly
		// if the invoking/parent Window is non-opaque using AWTUtilities#setWindowOpaque(window, false) or Window#setBackground(new Color(0, 0, 0, 0)).
		// This problem appears on JDK-6(x86/amd64) and JDK-7(x86/amd64)

		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				//final JFrame window = new JFrame();
				//window.setUndecorated(true);
				final JWindow window = new JWindow();
				window.setLocation(200, 200);
				window.setSize(300, 300);

				final JLabel label = new JLabel("...click to invoke JPopupMenu");
				label.setOpaque(true);
				final JPanel contentPane = new JPanel(new BorderLayout());
				contentPane.setBorder(BorderFactory.createLineBorder(Color.RED));
				window.setContentPane(contentPane);
				contentPane.add(label, BorderLayout.NORTH);

				final JComboBox comboBox = new JComboBox(new Object[] {"1", "2", "3", "4"});
				contentPane.add(comboBox, BorderLayout.SOUTH);

				final JPopupMenu jPopupMenu = new JPopupMenu();

				jPopupMenu.add("string");
				jPopupMenu.add(new AbstractAction("action") {
					@Override
					public void actionPerformed(final ActionEvent e) {
					}
				});
				jPopupMenu.add(new JLabel("label"));
				jPopupMenu.add(new JMenuItem("MenuItem"));
				label.addMouseListener(new MouseAdapter() {
					@Override
					public void mouseReleased(final MouseEvent e) {
						jPopupMenu.show(label, 0, 0);
						//jPopupMenu.repaint(); // this fixes JPopup painting in non-opaque Window's
					}
				});

				// Window.setBackground(Color). Passing the new Color(0, 0, 0, 0) achieves the old effect of installing per-pixel translucency.
				window.setBackground(new Color(0, 0, 0, 0));

				window.setVisible(true);

			}
		});
	}

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Note: only for JPopupMenu not JCombobox
-----------------------------------------------------------------

after #show call repaint

jPopupMenu.show(label, 0, 0);
jPopupMenu.repaint(); // this fixes JPopup painting in non-opaque Window's
Same issue had been reported by a CAP member:

we experience many issues with tansclucent windows with JDK 7. All issues are 
new and were working with JDK 6. We already cross-checked with JDK 8, still
broken.

The last version of the test case is attached(GuiTest_AwtUtilitiesWrapper.java)

This is a serious problem on all Windows systems. If heavyweight popup is 
needed and D3D-Pipeline is not active. E.g. JComboBox-Popus are heavyweight 
if they exceed the bounds of the window they are embedded in. Opacity is not
usable in current state. Attached "Translucent_windows.png" shows a non-working
windows system.

Hint: Test cases 2 and 3 at http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html 
are broken (in jnlp file for test case 2 the main class is missing, in test 
case 3 the wrong main class is referenced). These test cases could be used to
show some of the issues. See attached screenshot "Translucent_ubuntu.png", 
taken with Ubuntu 12.04 and Intel GMA graphics.

Another "translucent window issue":
On JWindows/JFrames on Linux/X11 using Nvidia Twin View (latest nvidia X11
graphics driver) - If your using non-opaque windows on Linux/X11 using Nvidia
Twin View (dual monitor setup) on X11 - Translucency of the JWindow is lost
immediately if moving the non-opaque JWindow from the primary screen to 
secondary one. This happens only with jdk7u7 and before. With jdk6 all is 
painted fine. 
nvidia driver: 302.17
X11 version: 1.12.3 (11203000)
X11 version number: 11.0
nvidia- twin config: see screen attached "nvidia-driver-config.png"

Comments
Release team: Approved for fixing
25-11-2013

SQE: OK to push in jdk8
22-11-2013

Webrev: http://cr.openjdk.java.net/~bagiras/7160604.2/ Review: http://mail.openjdk.java.net/pipermail/awt-dev/2013-November/006375.html Impact: affects only drop-down list of JComboBox on Windows. Rational: is't a long-awaited CAP issue. Risk level: Low. Affected component: javax.swing.JComboBox. Regression test added.
22-11-2013

Yes, it's reproducible on Ubuntu and Windows, but problems are different. Please, read my comment above on 2013-10-10 17:06.
11-11-2013

is it reproducible on jdk8?
11-11-2013

CAP member is very disappointed that there seems no backmerge path to jdk 8 or 7. Even if there is a workaround mentioned, this is not feasible for the CAP members for various reasons and they would like ask to address in jdk 7 update releases and 8 instead wait until 9.
08-11-2013

RT NOTE: Client (bulk) The criteria for deferral bulk request bugs: - Not P2 - Not tck-red - Not critical to customer Approved.
11-10-2013

jdk8: SQE OK to defer. But imho it would be bad publicity to keep this broken much longer.
10-10-2013

This issue was created 1,5 year ago, it could be reproduced on JDK 7 GA with Windows 7. Moreover there is the workaround from the customer, so I propose to defer this issue.
10-10-2013

Description to the attached screenshots: 1. Mac OS X 10.8.3 (mac.png) test works as it should with all versions of JDK 2. Windows 7 (win7ga.png) JDK 7 GA and 7u, with or without D3D enabled - popup-menu and drop-down list have no items until you hover them, and no border - always. JDK 8 without D3D behaves the same way as JDK 7, with D3D enabled shows popup-menu items and border as it should, shows drop-down list items and border only for the first show, then works as JDK 7. 3. Ubuntu 12.04 JDK 7 GA works as it should without XRender enabled. JDK 7u40 works almost the same way, except popup-up menu, which is not hidden after first show and stays partly covered by its ancestor dialog (ubuntu7u40.png). JDK 8 works the same way as JDK 7u40, but as XRender enabled by default, background is black (instead of being transparent) (ubutu8xrender.png).
10-10-2013

Not a regression in JDK8, introduced in JDK7u3. CAP more than 1 year old.
22-08-2013

can we fix it in 7u ?
08-08-2013

EVALUATION The submitter sent screenshots with comments The problem exists with jdk8 on the submitter's host. Java flag -Dsun.java2d.d3d=true solves the problem on the submitter's host. Screenshot 1. "only the first item is painted. if moving the mouse pointer over the popup the other 3 items are painted successively" Screenshot 2. "popup-menu paints not correct, popup-menu correct painted" Screenshot 3 "The screenshots show the combobox problem." Screenshot 4 "after moving the mouse pointer, combobo entries are correct painted"
16-04-2012

WORK AROUND Java flag -Dsun.java2d.d3d=true solves the problem.
16-04-2012

EVALUATION I tried to reproduce the problem with the same OS, the same JDKs. Without success.
13-04-2012