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

java.awt.Dimension.setSize(double, double) is poorly documented

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: dsR10051 Date: 12/28/2000


      JavaDoc for method
      java.awt.Dimension.setSize(double, double)
      says nothing about it behavior when any of parameters is
      more then Integer.MAX_VALUE.
      In this case method set the appropriate integer property
      to Integer.MAX_VALUE. This behavior should be documented.

      Here is a minimized test:
      --- DimTest01.java ---
      import java.awt.Dimension;

      public class DimTest01 {

          public static void main(String[] args) {

              Dimension dim = new Dimension();
              // double width = ((double)Integer.MAX_VALUE) + 1.0d;
              double width = Double.MAX_VALUE;
              dim.setSize(width, 0.0d);

              System.out.println("Dimension: " + dim);
              System.out.println("width: " + dim.getWidth());
              System.out.println("expected: " + width);
              if (dim.getWidth() == ((double) Integer.MAX_VALUE)) {
                  System.out.println("Dimension has Integer.MAX_VALUE width");
              }
          }
      }
      --- Outlut ---
      %java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
      Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)
      %java DimTest01
      Dimension: java.awt.Dimension[width=2147483647,height=0]
      width: 2.147483647E9
      expected: 1.7976931348623157E308
      Dimension has Integer.MAX_VALUE width

      ======================================================================

            sharonz Sharon Zakhour (Inactive)
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: