<Swing Dev> [12] RFR: JDK-8205535:Useless (or buggy) call to Math.round on int input
Prasanta Sadhukhan
prasanta.sadhukhan at oracle.com
Thu Jul 19 09:24:25 UTC 2018
Hi All,
Please review a simple fix to rectify invocation of Math.round() with
double/float value instead of int
---
a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
Fri Jun 15 13:07:46 2018 -0700
+++
b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
Thu Jul 19 14:51:20 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 + 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 + Math.round(height/2.0 - stringWidth/2.0));
}
}
Similar thing was done for
protected int getBoxLength(int availableLength, int otherDimension) {
return (int)Math.round(availableLength/6.0);
}
Regards
Prasanta
More information about the swing-dev
mailing list