From 34dba2fa8cc5f10a4458f5f0478f6bddddb7c92f Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 7 Dec 2016 17:54:55 +0300 Subject: [PATCH] 8160441: [PIT][TEST_BUG][macosx] javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java Reviewed-by: ssadetsky, yan --- .../JComboBox/8041909/ActionListenerExceptionTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java b/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java index c7ea83f3b02..7bf4a440585 100644 --- a/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java +++ b/jdk/test/javax/swing/JComboBox/8041909/ActionListenerExceptionTest.java @@ -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.JComboBox; 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 @@ public class ActionListenerExceptionTest { 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;