How to set custom size for cursor in swing?
        Posted  
        
            by swift
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by swift
        
        
        
        Published on 2010-04-12T06:17:17Z
        Indexed on 
            2010/04/12
            6:23 UTC
        
        
        Read the original article
        Hit count: 392
        
I am using the below code to set a custom cursor for JPanel, but its enlarging the image which i set for cursor. Is there a way to set a customized cursor size ?
Toolkit toolkit = Toolkit.getDefaultToolkit();
BufferedImage erasor=new BufferedImage(10,10, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d=(Graphics2D) erasor.createGraphics();
g2d.setPaint(Color.red);
g2d.drawRect(e.getX(),e.getY() ,10, 10);
toolkit.getBestCursorSize(10, 10);
Cursor mcursor=toolkit.createCustomCursor(erasor, new Point(10,10), "Eraser");
setCursor(mcursor);
© Stack Overflow or respective owner