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

Method Polygon.getBounds() returns incorrect value.

XMLWordPrintable

    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 02/10/98


      Method Polygon.getBounds() returns incorrect value whenever another
      point is added to the polygon.

      The problem is originated from void Polygon.updateBounds().

      -------------------Example-----------------------------------
      import java.awt.*;

      public class Test {

         public static void main(String argv[]) {
              int x[]={2,2,2};
              int y[]={2,3,4};
              Polygon p=new Polygon(x,y,3);
              p.getBounds();
              p.addPoint(1,1);
              if(!p.getBounds().equals(new Rectangle(1,1,1,3)))
                    System.out.println("Failed. Incorrect bounds returned: "
                    +p.getBounds());
         }

      }


      -------------------Output------------------------------------
      Failed. Incorrect bounds returned: java.awt.Rectangle[x=1,y=1,width=0,height=2]


      Please note that this bug is already fixed in JDK 1.2. It exists
      only in versions 1.1.6 or earlier.


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

            dmendenhsunw David Mendenhall (Inactive)
            aalievsunw Artem Aliev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: