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

java.awt.Rectangle.inside doesn't work

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0beta
    • CPU:
      sparc
    • OS:
      solaris_2.4
    • Verification:
      Not verified

      Description

      Member function inside(int, int) of
      class java.awt.Rectangle does not work for
      rectangles with origin different from (0,0).
      Following is an example program. Its output is:
      point (5, 5) is inside java.awt.Rectangle[x=0,y=0,width=10,height=10]
      point (15, 15) is not inside java.awt.Rectangle[x=10,y=10,width=10,height=10]
      The second line is wrong.
      -------- Inside.java -----
      import java.awt.Rectangle;

      class Inside {

      private static void tryInside( Rectangle r, int x, int y ){
          System.out.print("point ("+x+", "+y+")" );
          System.out.print( r.inside( x, y )?" is ":" is not " );
          System.out.println("inside "+ r.toString() );
      }

      public static void main( String ignore[] ) {
          // rectangle at origin. 10 units on a side.
          Rectangle tenByTen = new Rectangle( 0, 0, 10, 10 );
          // point (5,5) should be inside this rectangle
          tryInside( tenByTen, 5, 5 );
          // now move the 10x10 rectangle to point (10,10)
          tenByTen.move( 10, 10 );
          // point (15,15) should be inside this rectangle
          tryInside( tenByTen, 15, 15 );
      }
      }

        Attachments

          Activity

            People

            Assignee:
            sshaiosunw Sami Shaio (Inactive)
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: