-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b130
-
generic
-
generic
-
Verified
JDK 7b118+
Platform : All
Method of the class javax.swing.border.StrokeBorder
public Insets getBorderInsets(Component c, Insets insets) {}
says:
* Reinitializes the {@code insets} parameter
* with this border's current insets.
* All insets are equal to the line width of the stroke.
This assertion is unclear and not always satisfied as Insets() hold integers while line width is float.
Please see the following code sample:
-----------------------------------------------------------------------
import javax.swing.*;
import javax.swing.border.StrokeBorder;
import java.awt.*;
import java.awt.image.BufferedImage;
public class GetBorderInsets {
public static void main(String[] args) {
float lineWidth = 1.0001f;
StrokeBorder strokeBorder =
new StrokeBorder(new BasicStroke(lineWidth), Color.BLACK);
Insets insets = new Insets(0, 0, 0, 0);
JPanel component = new JPanel();
component.setBorder(strokeBorder);
System.out.println("returned insets = " +
strokeBorder.getBorderInsets(component, insets));
}
}
-----------------------------------------------------------------------
The output will be:
strokeBorder.getBorderInsets(Component, insets) = java.awt.Insets[top=2,left=2,bottom=2,right=2]
Spec has to mention the way how float values are converted to integer
Platform : All
Method of the class javax.swing.border.StrokeBorder
public Insets getBorderInsets(Component c, Insets insets) {}
says:
* Reinitializes the {@code insets} parameter
* with this border's current insets.
* All insets are equal to the line width of the stroke.
This assertion is unclear and not always satisfied as Insets() hold integers while line width is float.
Please see the following code sample:
-----------------------------------------------------------------------
import javax.swing.*;
import javax.swing.border.StrokeBorder;
import java.awt.*;
import java.awt.image.BufferedImage;
public class GetBorderInsets {
public static void main(String[] args) {
float lineWidth = 1.0001f;
StrokeBorder strokeBorder =
new StrokeBorder(new BasicStroke(lineWidth), Color.BLACK);
Insets insets = new Insets(0, 0, 0, 0);
JPanel component = new JPanel();
component.setBorder(strokeBorder);
System.out.println("returned insets = " +
strokeBorder.getBorderInsets(component, insets));
}
}
-----------------------------------------------------------------------
The output will be:
strokeBorder.getBorderInsets(Component, insets) = java.awt.Insets[top=2,left=2,bottom=2,right=2]
Spec has to mention the way how float values are converted to integer
- relates to
-
JDK-4358979 javax.swing.border should have a DashedBorder
- Closed