-
Enhancement
-
Resolution: Fixed
-
P3
-
1.0
-
1.1beta3
-
sparc
-
solaris_2.5
-
Not verified
This could easily be read as an RFE. Feel free to change it to that if more appropriate.
From: tmb
This does not look like form output to me.
The Java/AWT API makes no static distinction between (what in X11
language would be called) a Drawable and an Image. This can cause
unpleasant unexpected errors from deep within Motif. Below is an
example. Given that Java has a static type system, it would be nice
if it could be used to make the distinction between Drawable and
Image. In fact, even without that distinction, why does getGraphics()
even succeed?
Thomas.
This log happens to be on Linux/X11R6, but the same problem occurs on
Windows 95. This is in JDK-1.0.
tardis$ cat Bug3.java
import java.awt.*;
import java.awt.image.*;
import java.net.*;
import java.applet.*;
import java.util.Vector;
import java.lang.*;
import java.io.*;
import sun.awt.image.FileImageSource;
class Bug3 extends Canvas {
Image image = null;
Graphics ig;
public void paint(Graphics g) {
if(image==null) {
int pixels[] = new int[25];
for(int i=0;i<25;i++) pixels[i] = 0;
image = createImage(new MemoryImageSource(5,5,pixels,0,5));
ig = image.getGraphics();
ig.setColor(Color.black);
ig.fillRect(0,0,1000,1000);
}
g.drawImage(image,0,0,this);
}
public static void main(String args[]) {
Frame f = new Frame("Test");
Bug3 c = new Bug3();
c.resize(100,100);
f.add("Center",c);
f.pack();
f.show();
}
static void D(String s) { System.out.println(s); }
}
tardis$ java Bug3
java.lang.ClassCastException: java.awt.image.MemoryImageSource
at sun.awt.motif.X11Graphics.<init>(X11Graphics.java:49)
at sun.awt.motif.X11Image.getGraphics(X11Image.java:42)
at Bug3.paint(Bug3.java:19)
at sun.awt.motif.MComponentPeer.paint(MComponentPeer.java:123)
at sun.awt.motif.MComponentPeer.handleExpose(MComponentPeer.java:262)
at java.lang.Thread.run(Thread.java)
tardis$
From: tmb
This does not look like form output to me.
The Java/AWT API makes no static distinction between (what in X11
language would be called) a Drawable and an Image. This can cause
unpleasant unexpected errors from deep within Motif. Below is an
example. Given that Java has a static type system, it would be nice
if it could be used to make the distinction between Drawable and
Image. In fact, even without that distinction, why does getGraphics()
even succeed?
Thomas.
This log happens to be on Linux/X11R6, but the same problem occurs on
Windows 95. This is in JDK-1.0.
tardis$ cat Bug3.java
import java.awt.*;
import java.awt.image.*;
import java.net.*;
import java.applet.*;
import java.util.Vector;
import java.lang.*;
import java.io.*;
import sun.awt.image.FileImageSource;
class Bug3 extends Canvas {
Image image = null;
Graphics ig;
public void paint(Graphics g) {
if(image==null) {
int pixels[] = new int[25];
for(int i=0;i<25;i++) pixels[i] = 0;
image = createImage(new MemoryImageSource(5,5,pixels,0,5));
ig = image.getGraphics();
ig.setColor(Color.black);
ig.fillRect(0,0,1000,1000);
}
g.drawImage(image,0,0,this);
}
public static void main(String args[]) {
Frame f = new Frame("Test");
Bug3 c = new Bug3();
c.resize(100,100);
f.add("Center",c);
f.pack();
f.show();
}
static void D(String s) { System.out.println(s); }
}
tardis$ java Bug3
java.lang.ClassCastException: java.awt.image.MemoryImageSource
at sun.awt.motif.X11Graphics.<init>(X11Graphics.java:49)
at sun.awt.motif.X11Image.getGraphics(X11Image.java:42)
at Bug3.paint(Bug3.java:19)
at sun.awt.motif.MComponentPeer.paint(MComponentPeer.java:123)
at sun.awt.motif.MComponentPeer.handleExpose(MComponentPeer.java:262)
at java.lang.Thread.run(Thread.java)
tardis$