Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Larger cursor in Java

Is there a possibility to create a larger cursor (by the method createCustomCursor()) than the predefined 32x32 in Windows (e.g. 64x64 or even more)?

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);

I tried the following:

 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);
       }

But it doesn't work, the whole GUI disappears, and the cursor is drawn at every point so i have to delete it in a way?

like image 847
processWatcher Avatar asked Mar 22 '26 17:03

processWatcher


1 Answers

Is there a method to make a cursor smaller than the predefined 32x32? If so just make a cursor so tiny that it really can't be noticed, or make a transparent cursor... THEN, just move an image to the coordinates of the cursors current location every (insert desired time interval here)

like image 83
Albert Renshaw Avatar answered Mar 25 '26 06:03

Albert Renshaw