changeset 12527:feb82820f27d

8028618: [TEST BUG] javax/swing/JScrollBar/bug4202954/bug4202954.java fails Reviewed-by: alexsch, azvegint Contributed-by: nadeesh.tv@oracle.com
author kshefov
date Wed, 05 Aug 2015 16:35:41 +0300
parents d400f76e5c48
children 133282574936
files test/javax/swing/JScrollBar/bug4202954/bug4202954.java
diffstat 1 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/test/javax/swing/JScrollBar/bug4202954/bug4202954.java	Tue Aug 04 11:31:19 2015 -0700
+++ b/test/javax/swing/JScrollBar/bug4202954/bug4202954.java	Wed Aug 05 16:35:41 2015 +0300
@@ -53,8 +53,8 @@
 
         if (rightScrollButton == null || bottomScrollButton == null) {
             String errMessage = "Test can't be executed: ";
-            errMessage = errMessage + rightScrollButton == null ? "can't find right button for horizontal scroll bar; " : ""
-                    + bottomScrollButton == null ? "can't find bottom scroll button for vertical scroll bar" : "";
+            errMessage = errMessage + (rightScrollButton == null ? "can't find right button for horizontal scroll bar; " : ""
+                    + (bottomScrollButton == null ? "can't find bottom scroll button for vertical scroll bar" : ""));
             throw new RuntimeException(errMessage);
         }
 
@@ -105,15 +105,25 @@
         JButton button = Util.invokeOnEDT(new java.util.concurrent.Callable<JButton>() {
             @Override
             public JButton call() throws Exception {
-                for (Component c: scrollBar.getComponents()) {
-                    if (c instanceof JButton) {
-                        Point p = c.getLocationOnScreen();
-                        if (p.x > minX && p.y > minY) {
-                            return (JButton) c;
-                        }
-                    }
-                }
-                return null;
+                int currentXorY = 0;
+                JButton scrollButton = null;
+                 for (Component c: scrollBar.getComponents()) {
+                     if (c instanceof JButton) {
+                         Point p = c.getLocationOnScreen();
+                         if (scrollBar.getOrientation() == Adjustable.VERTICAL){
+                             if (currentXorY <= p.y){
+                                 currentXorY = p.y;
+                                 scrollButton = (JButton)c;
+                             }
+                         }else  if (scrollBar.getOrientation() == Adjustable.HORIZONTAL){
+                             if (currentXorY <= p.x){
+                                 currentXorY = p.x;
+                                 scrollButton = (JButton)c;
+                             }
+                         }
+                     }
+                 }
+                return scrollButton;
             }
         });
         return button;