createCustomCursormethod to use your images in any respectful way. The behaviour of this method is to resize the image into the dimensions returned by the
getBestCursorSizemethod, which on Windows XP always seems to return 32x32 pixels.
To me this seems pretty crap because the image is going to get resized at some point depending on the platform your app is being run on which will most likely make the cursor image look terrible, perhaps to the user, unusable. IMO the behaviour should be to create a new image of the dimensions of
getBestCursorSizeand draw the supplied image at point 0,0. This does cause a problem if your image is larger than the dimension but your would be screwed the default way anyway.
Implementation is below...
public class SizedCursor
public static Image getPreferredSizedCursor(
Dimension bestDimension = Toolkit
BufferedImage resizedImage = new BufferedImage(
Graphics2D g = (Graphics2D) resizedImage
private static boolean bestDimensionsEqualsImageSize(
.getWidth() == image
.getHeight() == image