Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7001484

DOC: Method javax.swing.border.StrokeBorder.getBorderInsets() should specify how it converts float

    Details

    • Subcomponent:
    • Resolved In Build:
      b130
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                malenkov Sergey Malenkov (Inactive)
                Reporter:
                dbessono Dmitry Bessonov
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: