A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/javaexamples/gui_transparent.htm below:

How to create a transparent cursor in Java

How to create a transparent cursor in Java Problem Description

How to create a transparent cursor?

Solution

Following example demonstrates how to create a transparent cursor by using createCustomCursor() method with "invisiblecursor" as an argument.

import java.awt.*;
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");
      System.out.println("Transparent Cursor created.");
   }
}
Result

The above code sample will produce the following result.

Transparent Cursor created.

The following is an example to create a transparent cursor.

import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;

public class Panel {
   public static void main(String[] argv) throws Exception {
      JFrame frame = new JFrame();
      frame.setCursor(frame.getToolkit().createCustomCursor(
         new BufferedImage(3, 3, BufferedImage.TYPE_INT_ARGB), new Point(0, 0),"null"));
   }
}

java_simple_gui.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4