-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: gsC80088 Date: 11/19/98
Attempting to get an image of a component by
calling printAll() with a Graphics retrieved from
an off screen image throws a nasty.
Not verified yet on a single processor machine.
Not observed on Solaris.
import java.awt.*;
/**
* Code illustrating printAll bug.
*/
public class bugPanel extends Panel
{
void doPrint ()
{
{ // get an image of our component
Dimension size = getSize ();
Image image = createImage (size.width, size.height);
Graphics g = image.getGraphics ();
printAll (g);
g.dispose ();
}
}
public static void main (String[] args)
{
Frame f = new Frame ("printAll bug");
bugPanel bp = new bugPanel ();
bp.add (new Button ("Hello"));
f.add ("Center", bp);
f.setSize (100, 100);
f.setVisible (true);
bp.doPrint ();
f.addWindowListener (
new java.awt.event.WindowAdapter ()
{
public void windowClosing (java.awt.event.WindowEvent e)
{
System.exit (0);
}
});
}
}
Exception in thread "main" java.lang.ClassCastException: sun.awt.image.BufferedImageGraphics2D
at sun.awt.windows.WComponentPeer.print(WComponentPeer.java:93)
at sun.awt.windows.WCanvasPeer.print(WCanvasPeer.java:47)
at sun.awt.windows.WPanelPeer.print(WPanelPeer.java:24)
at java.awt.Component.printAll(Component.java:1738)
at bugPanel.doPrint(bugPanel.java:14)
at bugPanel.main(bugPanel.java:27)
(Review ID: 38385)
======================================================================
- duplicates
-
JDK-4189679 WComponentPeer.print() is doing an illegal cast, causes exception
-
- Resolved
-