Java自定义光标有时在MacOS上显示为默认值

Java自定义光标有时在MacOS上显示为默认值,java,macos,Java,Macos,在下面的代码示例中,光标将更改为您放置在“icon/cursor/”处的名称为“pointer measure.png”的32x32图像 问题是:在MacOS上,如果保持鼠标在帧内和帧外移动,有时会显示自定义图像,而其他时间则显示默认光标。我只在MacOS上观察到这种行为——如果我在Windows上运行相同的代码,每次都会显示自定义光标 有人有同样的问题吗?有解决办法吗 public class JavaApplication2 { public static final Cursor MOV

在下面的代码示例中,光标将更改为您放置在“icon/cursor/”处的名称为“pointer measure.png”的32x32图像

问题是:在MacOS上,如果保持鼠标在帧内和帧外移动,有时会显示自定义图像,而其他时间则显示默认光标。我只在MacOS上观察到这种行为——如果我在Windows上运行相同的代码,每次都会显示自定义光标

有人有同样的问题吗?有解决办法吗

public class JavaApplication2 {

public static final Cursor MOVE_CURSOR = getCustomCursor("pointer-measure.png", "bt-drawing", 15, 15);

public static void main(String[] args) {
    JFrame  frame = new JFrame();
    frame.setSize(300, 300);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.red));
    panel.setCursor(MOVE_CURSOR);

    frame.add(panel);
    frame.setVisible(true);
}

public static Cursor getCustomCursor(String filename, String cursorName, int hotSpotX, int hotSpotY) {
    Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
    ImageIcon icon = new ImageIcon(JavaApplication2.class.getResource("icon/cursor/" + filename));
    Dimension bestCursorSize = defaultToolkit.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
    Point hotSpot = new Point((hotSpotX * bestCursorSize.width) / icon.getIconWidth(),
        (hotSpotY * bestCursorSize.height) / icon.getIconHeight());
    return defaultToolkit.createCustomCursor(icon.getImage(), hotSpot, cursorName);
}

}

Obs:我在MacOS Sierra和Windows 10上运行。

我在OpenJDK站点上发现了一个错误报告:。但我没有使用OpenJDK,我使用的是oracle的Java8。