是否有可能在Windows中創建比預定義的32x32更大的遊標(通過方法createCustomCursor()
)(例如64x64甚至更多)?Java中的較大遊標
Toolkit toolkit = Toolkit.getDefaultToolkit();
final Image cursor = toolkit.getImage(getClass().getClassLoader().getResource("images/cursor.png"));
toolkit.getBestCursorSize(64, 64);
Cursor mycursor=toolkit.createCustomCursor(cursor, new Point(0,0), "cursor");
setCursor(mycursor);
我試過如下:
Cursor emptyCursor = Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), "empty");
setCursor(emptyCursor);
this.addMouseMotionListener(new MouseMotionListener(){
public void mouseDragged(MouseEvent e) {
}
public void mouseMoved(MouseEvent e) {
xCursor = e.getX();
yCursor = e.getY();
repaint();
//e.consume();
}
});
public void paint(Graphics g) {
g.drawImage(cursor, xCursor, yCursor, null);
}
但它不工作,整個GUI消失,並且光標在每一點上,所以我不得不刪除它的方式繪製的?
當您嘗試時發生了什麼?爲了更快地獲得更好的幫助,請發佈[SSCCE](http://sscce.org/)。 – 2013-02-19 00:31:36
實際上面的代碼創建了一個使用窗口大小爲32x32的光標..我想知道,如果存在一個更有效的方式來編寫一個更大的光標!? – processWatcher 2013-02-19 10:25:34
解決 http://stackoverflow.com/questions/18475404/java-does-a-mousemoved-event-and-a-button-addmouselistener-interfere – processWatcher 2014-01-07 23:46:33