看起来
Cursor类没有一个“空白”光标开始,所以可以使用
Toolkit.createCustomCursor方法定义一个新的“空白”光标。
这里有一种方法,我试过似乎工作:
// Transparent 16 x 16 pixel cursor image.
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
// Create a new blank cursor.
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
cursorImg, new Point(0, 0), "blank cursor");
// Set the blank cursor to the JFrame.
mainJFrame.getContentPane().setCursor(blankCursor);
编辑
关于JFrame中没有光标的所有内容的评论,看起来JFrame中包含的组件最终会继承容器的游标(JFrame),所以如果它是一个需要有一个特定组件有光标出现,必须手动设置所需的光标。
例如,如果JFrame中包含JPanel,那么可以使用Cursor.getDefaultCursor方法将该JPanel的光标设置为系统的默认值:
JPanel p = ...
// Sets the JPanel's cursor to the system default.
p.setCursor(Cursor.getDefaultCursor());