--- old/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 2018-02-22 16:04:08.063442943 +0530 +++ new/test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 2018-02-22 16:04:07.859340943 +0530 @@ -21,8 +21,21 @@ * questions. */ -import javax.swing.*; -import java.awt.*; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.RootPaneContainer; +import javax.swing.JList; +import javax.swing.JComboBox; +import javax.swing.JPopupMenu; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.GraphicsDevice; +import java.awt.Container; +import java.awt.BorderLayout; +import java.awt.Point; +import java.awt.Color; +import java.awt.Window; +import java.awt.EventQueue; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -53,6 +66,8 @@ JPanel north; volatile boolean southClicked = false; + JPopupMenu popup = null; + public static void main(String[] args) throws Exception { if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) for (Class windowClass: WINDOWS_TO_TEST) @@ -84,6 +99,24 @@ jComboBox.addItem("item " + i); } south = jComboBox; + jComboBox.addPopupMenuListener(new PopupMenuListener() { + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + popup = (JPopupMenu) jComboBox.getUI() + .getAccessibleChild(jComboBox, 0); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); south.addMouseListener(new MouseAdapter() { @Override @@ -142,7 +175,13 @@ ". Before click: " + c1 + ", after click: " + c1b + ", expected is " + south.getBackground()); - if (!c2.equals(c2b) && !south.getBackground().equals(c2b)) + //This following check is only valid if the popup was created below the + // JComboBox and will be opaque or it is created above the JComboBox + // and it can not fit inside the JWindow along with JComboBox and will + // be opaque + if ( !c2.equals(c2b) && !south.getBackground().equals(c2b) && + (popup.getLocationOnScreen().y > ls.y || + window.getHeight() < popup.getHeight() + south.getHeight())) throw new RuntimeException( "Check for opaque drop down failed at point " + p2 + ". Before click: " + c2 + ", after click: " + c2b +