Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:24:35+00:00 2026-06-11T19:24:35+00:00

I created a cursor using: BufferedImage im=null; try { im = ImageIO.read(new File(images/cursor1.jpg)); }

  • 0

I created a cursor using:

    BufferedImage im=null;
    try {
        im = ImageIO.read(new File("images/cursor1.jpg"));
    } catch (IOException ex) {
        Logger.getLogger(SRGView.class.getName()).log(Level.SEVERE, null, ex);
    }
    Cursor cursor = getToolkit().createCustomCursor(im, new Point(1,1), "s");
    this.setCursor(cursor);

The cursor1.jpg is 5X5 (in pixels). However, when it is displayed on the screen, it is much larger. I would like to make cursors of size 1X1, 5X5, 10X10. I would rather prefer creating the image dynamically than read the image file. i.e.

for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
        im.setRGB(x, y, new Color(255, 0, 0).getRGB());
  }
    }

The above code would create a red image “im” of width, w and height, h and I would like to use that as my cursor.

How to do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:24:36+00:00Added an answer on June 11, 2026 at 7:24 pm

    It seems like windows only accepts 32X32 sized cursors. So this is how I solved the problem:

    The main idea is to make every pixel in the 32X32 sized image transparent and apply color only to those pixels u want to see in the cursor. In this case, I want a w x h red rectangular cursor so, at the center of the 32X32 image, I set w x h pixels as red and set that image as the cursor.

    public void setCursorSize(int w, int h) {
        this.cw = w;
        this.ch = h;
        if (w > 32) {
            w = 32;
        }
        if (h > 32) {
            h = 32;
        }
        Color tc = new Color(0, 0, 0, 0);
        BufferedImage im = new BufferedImage(32, 32, BufferedImage.TYPE_4BYTE_ABGR);//cursor size is 32X32
        for (int x = 0; x < 32; x++) {
            for (int y = 0; y < 32; y++) {
                im.setRGB(x, y, tc.getRGB());
            }
        }
        for (int x = 16 - w / 2; x <= 16 + w / 2; x++) {
            for (int y = 16 - h / 2; y <= 16 + h / 2; y++) {
                im.setRGB(x, y, new Color(255, 0, 0).getRGB());
            }
        }
        this.setCursor(getToolkit().createCustomCursor(im, new Point(16, 16), "c1"));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created my own color theme using this website . I've added a new
Edited Post These are the new functions that I have created using your template
I created a python server on port 8000 using python -m SimpleHTTPServer . When
I have created a menu using a treeview to launch forms when the user
I created a setup using Inno installer, during the setup, I made some lengthly
I have an SQL file which uses declares a cursor and I am running
I have created a box using a div . <div class=panel style=display:inline; float:left;position: relative;
I just created an app for Android using Eclipse, and everything works, however, when
I've created a stored procedure. I fetch cursor with huge amount of data(around 1L
In Qt, a created lineEdit shows a text using the setText() method. But the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.