Use a semi-transparent image for the cursor. AFAIU the only image type understood by J2SE that supports partial transparency - is PNG.
Neither Metal nor the default Windows PLAF seems to support partial transparency in any way I understand it.
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.imageio.ImageIO;
import java.io.File;
import java.net.URL;
/** The example demonstrates how a semi-transparent image is
NOT supported as a cursor image. It is drawn as a solid color. */
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 upshot is - I was wrong. Using a semi-transparent icon will not achieve the goal.