It appears that the
Cursor
class does not have a "blank" cursor to begin with, so one could define a new "blank" cursor using the
Toolkit.createCustomCursor
method.
Here's one way I've tried which seems to work:
// 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);
Edit
Regarding the comment about everything inside the JFrame
ending up without a cursor, it seems that the Component
s which are contained in the JFrame
will end up inheriting the cursor of the container (the JFrame
), so if it is a requirement to have a certain Component
have the cursor appear, one would have to manually set the desired cursor.
For example, if there is a JPanel
contained in the JFrame
, then one could set the cursor of that JPanel
to the system's default using the Cursor.getDefaultCursor
method:
JPanel p = ...
// Sets the JPanel's cursor to the system default.
p.setCursor(Cursor.getDefaultCursor());
或者下面的程序
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
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");
}
}
===========================================
分享到:
相关推荐
swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3swing-layout-1.0.3...
swing计算器 swing计算器swing计算器 swing计算器swing计算器 swing计算器swing计算器 swing计算器swing计算器 swing计算器 简易计算器
swing 教程swing 教程swing 教程swing 教程swing 教程swing 教程swing 教程swing 教程swing 教程
java swing漂亮界面 超酷 javaswing教程
Swing插件,swing,java-swing swing-plugin下载
swing_hack,swing_hack,swing_hack,swing_hack
swing 鼠标事件 loading效果
Swing 扩展组件Swing 扩展组件Swing 扩展组件Swing 扩展组件
* JFrame 的关闭方式可以通过调用 setDefaultCloseOperation() 方法来设置,例如 EXIT_ON_CLOSE、DO_NOTHING_ON_CLOSE、DISPOSE_ON_CLOSE、HIDE_ON_CLOSE 等。 四、JDialog 窗体 * JDialog 是 Swing 组件中的...
java swing 教程 精通javaswing
swing组件封装重写
java_swing表格分页
Swing精美界面设计和动画制作教程+实例Swing精美界面设计和动画制作教程+实例Swing精美界面设计和动画制作教程+实例Swing精美界面设计和动画制作教程+实例Swing精美界面设计和动画制作教程+实例Swing精美界面...
Java Swing是目前图形界面设计的主流开发工具,《Java Swing图形界面开发与案例详解[1]》从实用的角度出发,通过大量实例全面介绍Java Swing中各种组件的应用及图形界面的开发技术。《Java Swing图形界面开发与案例...
spring+swing的例子 自己看资料写了个
JavaSwing.PPT (Swing 详解)
swing多tab页面板练习
Swing是一个用于开发Java应用程序用户界面的开发工具包。 以抽象窗口工具包(AWT)为基础使跨平台应用程序可以使用任何可插拔的外观风格。Swing开发人员只用很少的代码就可以利用Swing丰富、灵活的功能和模块化组件...
Java Swing JTable分页!JAVA源码!