Name: dsR10051 Date: 06/05/2000
The method java.awt.Toolkit.createCustomCursor(Image cursor, Point hotSpot, String name)
hangs the VM under Windows NT if cursor is multi-frame image.
Here is a minimized test:
import java.io.*;
import java.awt.*;
import java.awt.image.*;
public class TestToolkit {
public static void main(String[] args) {
try {
Toolkit tk = Toolkit.getDefaultToolkit();
String file = "file:///" + args[0] + "/31kb.gif";
System.out.println("File: " + file);
Image im = tk.getImage(new java.net.URL(file));
Canvas c = new Canvas();
if(!tk.prepareImage(im, -1, -1, c)) {
while((tk.checkImage(im, -1, -1,c) &
(ImageObserver.FRAMEBITS |
ImageObserver.ALLBITS)) == 0) {
Thread.yield();
}
}
System.out.println(tk.checkImage(im, -1, -1,c));
Point p = new Point(0,0);
System.out.println("Custom cursor creating");
Cursor cur = tk.createCustomCursor(im, p, "Test");
System.out.println("Custom cursor is successfully created");
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Multi-frame image "31kb.gif" is attached.
--- Output ---
F:\NightlyNT\BIN\Tests>f:\NightlyNT\java\jdk1.3\win32\bin\java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
F:\NightlyNT\BIN\Tests>f:\NightlyNT\java\jdk1.3\win32\bin\java -classpath . TestToolkit f:/NightlyNT/BIN/Tests
File: file:///f:/NightlyNT/BIN/Tests/31kb.gif
23
Custom cursor creating
^C
======================================================================