Use a translucent image for the cursor. AFAIU the only image type that J2SE understands that supports partial transparency is PNG.
Neither Metal nor Windows PLAF support partial transparency by default, I understand that.
import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.*; import javax.imageio.ImageIO; import java.io.File; import java.net.URL; class SemiTransparentCursor { public static void main(String[] args) { final BufferedImage biPartial = new BufferedImage( 32, 32, BufferedImage.TYPE_INT_ARGB); Graphics2D g = biPartial.createGraphics(); g.setColor(new Color(255,0,0,63)); int[] x = {0,32,0}; int[] y = {0,0,32}; g.fillPolygon(x,y,3); g.dispose(); final Cursor watermarkCursor = Toolkit.getDefaultToolkit(). createCustomCursor( biPartial, new Point(0, 0), "watermarkCursor"); SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog( null, new ImageIcon(biPartial)); JEditorPane jep = new JEditorPane(); jep.setPreferredSize(new Dimension(400,400)); jep.setCursor(watermarkCursor); try { URL source = new File("SemiTransparentCursor.java"). toURI().toURL(); jep.setPage(source); } catch(Exception e) { e.printStackTrace(); } JOptionPane.showMessageDialog( null, jep); } }); } }
The result - I was wrong. Using a translucent icon will not achieve the goal.
source share