Details
-
Type:
Bug
-
Status: Closed
-
Priority:
P3
-
Resolution: Fixed
-
Affects Version/s: 1.0
-
Fix Version/s: 1.0
-
Component/s: client-libs
-
Labels:
-
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 );
}
}
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 );
}
}