Download this source file
// CopyTest.java - Shows Graphics are references to copies of the graphic context.
// The circle changes to red only after a second call to paint.
//
// (c) 2000 by Wayne Pollock, Tampa FL USA. All Rights Reserved.
/*
*/
import java.awt.*;
import java.applet.*;
public class CopyTest extends Applet
{
public void paint( Graphics g )
{
g.drawString( "A red circle", 60, 15 );
// Note that g.setColor would change this copy but not the original.
// setForground changes the original, but not the copy passed to paint.
setForeground( Color.red );
g.fillOval( 40, 30, 100, 100 );
}
}