8028618: [TEST BUG] javax/swing/JScrollBar/bug4202954/bug4202954.java fails
Reviewed-by: alexsch, azvegint
Contributed-by: nadeesh.tv@oracle.com
--- a/jdk/test/javax/swing/JScrollBar/bug4202954/bug4202954.java Tue Aug 04 11:31:19 2015 -0700
+++ b/jdk/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;