# HG changeset patch # User yan # Date 1481122495 -10800 # Node ID 67c248b945d5f0ddd8acfe1f1a5c6c9ad8c3c19d # Parent b37da02bd6c19f90156828a8b2fc072eeb417873 8160441: [PIT][TEST_BUG][macosx] javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java Reviewed-by: ssadetsky, yan Contributed-by: Alexander Popov diff -r b37da02bd6c1 -r 67c248b945d5 jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java --- a/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java Wed Dec 07 11:37:04 2016 +0530 +++ b/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java Wed Dec 07 17:54:55 2016 +0300 @@ -26,7 +26,7 @@ * @summary Test to check JComboBox does not lose its ability to invoke * registerd ActionListener in case of exception in ActionListener * @run main ActionListenerExceptionTest - */ + */ import java.awt.AWTEvent; import java.awt.AWTException; @@ -44,6 +44,7 @@ import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; import javax.swing.SwingUtilities; public class ActionListenerExceptionTest { @@ -133,7 +134,11 @@ SwingUtilities.invokeAndWait(new Runnable() { public void run() { Object comp = combo.getUI().getAccessibleChild(combo, 0); - JComponent scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(0); + int i = 0; + JComponent scrollPane; + do { + scrollPane = (JComponent) ((JPopupMenu) comp).getComponent(i++); + } while (!(scrollPane instanceof JScrollPane)); menuItemHeight = scrollPane.getSize().height / TOTAL_MENU_ITEMS; yPos = scrollPane.getLocationOnScreen().y + menuItemHeight / 2;