Hmmm..

Take a look at this code snipit:

public void paint(Graphics g)

{

...

Shape oldClip = g2.getClip();

Rectangle rr = oldClip.getBounds();

System.out.print("Before:");

System.out.print(rr.getX());

System.out.print(",");

System.out.print(rr.getY());

System.out.print(",");

System.out.print(rr.getWidth());

System.out.print(",");

System.out.println(rr.getHeight());

g2.clip(new Rectangle(400, 400));

g2.drawImage(d_img, x, y, null);

g2.clip(oldClip);

oldClip = g2.getClip();

rr = oldClip.getBounds();

System.out.print("After:");

System.out.print(rr.getX());

System.out.print(",");

System.out.print(rr.getY());

System.out.print(",");

System.out.print(rr.getWidth());

System.out.print(",");

System.out.println(rr.getHeight());

...

}

Anyone know why it would produce the following output?

Before:0.0,0.0,896.0,493.0

After:0.0,0.0,400.0,400.0

Before:0.0,0.0,896.0,493.0

After:0.0,0.0,400.0,400.0

[1090 byte] By [Will2Playa] at [2007-10-3 10:12:34]
# 1
g2.clip(new Rectangle(400, 400));
CaptainMorgan08a at 2007-7-15 5:32:47 > top of Java-index,Desktop,Core GUI APIs...
# 2

And then there's the line:

g2.clip(oldClip);

It doesn't matter what I put in that line.I've tried 'oldClip', 'new Retangle(900, 500)', and various other shapes and sizes. The clip stays at Rectangle(400, 400), regardless of the second clip setting. However, it does return to Rectangle(896,493) when paint is called again.

I

Will2Playa at 2007-7-15 5:32:47 > top of Java-index,Desktop,Core GUI APIs...
# 3
I have other, relatively simple, programs in which the clipping mechansim works as expected.The progrram which contains the .above lines has a more complicated display. I guess this is just a bug in Java 5.0.
Will2Playa at 2007-7-15 5:32:47 > top of Java-index,Desktop,Core GUI APIs...