Skip to main content

what about custom mouse cursors?

4 replies [Last post]
daniil_kolpakov
Offline
Joined: 2006-01-21

Does anyone notice that the custom-created mouse cursors (via java.awt.Toolkit) are not... hmm... too colorful? Both Windows and Xorg allow mouse cursors with alpha channel now, let alone OS X.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
olsonje
Offline
Joined: 2005-08-10

I've heard a lot of complaints about cursors lately, doesn't sound fun. gfx might have something for you on that, as I know he was talking about cursors in blogs lately.

daniil_kolpakov
Offline
Joined: 2006-01-21

Thanks for reply!

I've written a very simple test,

----------------------------------------------------
import java.awt.*;

public class CursorTest extends Frame{
private Image image;

public CursorTest(Image image){
this.image = image;
Image cursorImage = image;
setCursor(getToolkit().createCustomCursor(cursorImage, new Point(0, 0), "Test"));
setSize(300, 300);
}
public void paint(Graphics g){
Insets insets = getInsets();
Dimension size = getSize();
int x = (size.width - insets.left - image.getWidth(null))/2 + insets.left;
int y = (size.height - insets.top - image.getHeight(null))/2 + insets.top;
g.drawImage(image, x, y, null);
}
public static void main(String[] args) throws Throwable{
new CursorTest(javax.imageio.ImageIO.read(new java.io.File(args[0]))).setVisible(true);
}
}
----------------------------------------------------

It loads image from the filename supplied from command line and sets this image as a cursor image, as you can see. On the every single image I've tried the cursor is two-color (hovewer, colors are different for each image). It happens with Java 5.0/Linux as well. Is it a bug? Hard to believe that nobody noticed.

Sorry - I've forgot to mention: I'm using Linux (Mandrive Cooker) with Xorg 6.9, and the Java is "build 1.6.0-rc-b68".

Message was edited by: daniil_kolpakov

olsonje
Offline
Joined: 2005-08-10

I just tried your example on Java5/winXP using a file I made really fast & a couple of big images(yea it looks bad but hey, hehe) and it seemed to work just fine. Perhaps its a linux thing? I don't have a mustang snapshot on here or I'd try that, sorry.

I hope someone from sun, or someone else for that matter, can help you on this. I have no clue outside of what I tried. Sorry.

daniil_kolpakov
Offline
Joined: 2006-01-21

Yes, I think it's a Linux-only thing then. Should I fill a bug report?