-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6
-
1.1.8
-
generic, sparc
-
generic, solaris_2.6
-
Verified
Name: chT40241 Date: 08/05/98
This code shows a bug with setClip(null) on Solaris JDK 1.1.6 & 1.1.7. This code works correctly under JDK 1.2 and correctly under 1.1.x Win32 JDK. The problem occurs when setting the clip to null to reset it. Setting the clip to null does not reset the clip on 1.1.x Solaris JDK; rather, the clip remains what it was even though getClip() returns the correct value of null.
**** ClipBug.java ****
import java.awt.*;
public class ClipBug extends Frame {
public ClipBug() {
super("Clip Bug");
}
public static void main(String args[]) {
System.out.println("This code shows a bug with setClip(null) on Solaris\n" +
"JDK 1.1.6 & 1.1.7. This code works correctly under\n" +
"JDK 1.2 and correctly under 1.1.x Win32 JDK. The\n" +
"problem occurs when setting the clip to null to\n" +
"reset it. Setting the clip to null does not reset\n" +
"the clip on 1.1.x Solaris JDK; rather, the clip\n" +
"remains what it was even though getClip() returns\n" +
"the correct value of null.\n");
Frame f = new ClipBug();
f.setBounds(30, 30, 200, 200);
f.setBackground(Color.white);
f.setVisible(true);
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
g.setClip(null);
Shape clip = g.getClip();
System.out.println("original clip shape is " + clip);
g.setClip(new Rectangle(40, 40, 80, 80));
System.out.println("for black line, clip is " + g.getClip());
g.setColor(Color.black);
g.drawLine(0, 0, 200, 200);
g.setClip(new Rectangle(20, 20, 120, 120));
System.out.println("for blue line, clip is " + g.getClip());
g.setColor(Color.blue);
g.drawLine(0, 200, 200, 0);
System.out.println("setting clip back to original value");
g.setClip(clip);
System.out.println("for green line, clip is " + g.getClip());
System.out.println("green line should be across ENTIRE frame");
g.setColor(Color.green);
g.drawLine(0, 100, 200, 100);
}
}
======================================================================