Hide the mouse cursor by using a transparent GIF as the cursor in Java

Description

The following code shows how to hide the mouse cursor by using a transparent GIF as the cursor.

Example


  /*w  w w  .  j  a  va 2 s .c o m*/

import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.MemoryImageSource;

public class Main {
  public static void main(String[] argv) throws Exception {

    int[] pixels = new int[16 * 16];
    Image image = Toolkit.getDefaultToolkit().createImage(
        new MemoryImageSource(16, 16, pixels, 0, 16));
    Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(
        image, new Point(0, 0), "invisibleCursor");
  }
}




















Home »
  Java Tutorial »
    Graphics »




Animation
BufferedImage
Color
Font
Gradient
Graphics Settings
Image
Mouse Draw
Print
Shape
Text
Transform