8205535: Useless (or buggy) call to Math.round on int input
authorpsadhukhan
Wed, 25 Jul 2018 15:36:37 +0530
changeset 51901 3f5a55b6bad8
parent 51168 17148c9457a6
child 51902 36bc2044b15c
8205535: Useless (or buggy) call to Math.round on int input Reviewed-by: jdv
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java	Thu Jul 19 10:53:38 2018 -0700
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java	Wed Jul 25 15:36:37 2018 +0530
@@ -874,7 +874,7 @@
                                                       progressString);
 
         if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
-            return new Point(x + Math.round(width/2 - stringWidth/2),
+            return new Point(x + (int)Math.round(width/2.0 - stringWidth/2.0),
                              y + ((height +
                                  fontSizer.getAscent() -
                                  fontSizer.getLeading() -
@@ -882,7 +882,7 @@
         } else { // VERTICAL
             return new Point(x + ((width - fontSizer.getAscent() +
                     fontSizer.getLeading() + fontSizer.getDescent()) / 2),
-                    y + Math.round(height/2 - stringWidth/2));
+                    y + (int)Math.round(height/2.0 - stringWidth/2.0));
         }
     }