How could I change custom cursor size? I was playing with Point(a,b), however the cursor is always 32x32 and it looks horribly. Below you can see my code snippet. Thanks!

Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image imageCrossCursor = toolkit.getImage(BeadToolbarColor.class.getResource("/icons/cross_cursor.png"));
        cross_cursor = toolkit.createCustomCursor(imageCrossCursor, new Point(0,0), "Cross cursor");

Recommended Answers

All 2 Replies

Hey, this is a small class I wrote that has a method for resizing an image

import javax.swing.ImageIcon;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.AlphaComposite;
import javax.swing.JPanel;
import javax.swing.JFrame;

public class ImageResize extends JPanel{

private Image img;
private int width,height;

public ImageResize(){

	ImageIcon ii = new ImageIcon(this.getClass().getResource("alienShip.png"));
	img = ii.getImage();


 public void paintComponent(Graphics g){
        Graphics2D g2d = (Graphics2D) g;


	public void drawStockImage(Graphics2D g){

public void resizeImage(Image i,Graphics2D g){

	int w = i.getWidth(null);
	int h = i.getHeight(null);
	h += h;
	g.drawImage(i, 70, 70, w, h, null);

		public static void main(String[] args){

			JFrame frame = new JFrame("hello");
			frame.add(new ImageResize());



Thank you for your code, but I'm not sure that it can completely solve the problem. Look at this thread: http://www.jguru.com/faq/view.jsp?EID=9958. People say that the image for a custom cursor will be enlarged if it is smaller than 32*32 (pixels). My problem is that I tried to change the image size to 32*32, but still the custom cursor is enlarged and looks really horrible. Any solutions? Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.