how to get transparency into cursor?

Discussion in 'Java' started by Tim, Aug 14, 2003.

  1. Tim

    Tim Guest

    I am writing an app that has a "palette" of small images(32x32) used
    to draw onto the screen. I want the cursor to change to be the
    currently selected palette image.
    I have that part working, where I run into trouble is when I scale the
    image down (zoom out) and make the cursor image smaller. My palette
    image gets painted into the cursor at the correct size, but I cannot
    make the remaining unused area of the cursor go transparent. Changing
    the alpha value of bgColor only changes the remaining area as if it
    were viewing the transparent color on a black background.

    Any help will be greatly appreciated.

    Thanks,
    Tim

    pnlCursor.setLayout(null);
    pnlCursor.setVisible(true);
    pnlCursor.setSize(new java.awt.Dimension(intImageSize,intImageSize));
    pnlCursor.setBackground(new Color(0,0,0,0));
    add(pnlCursor);

    imgCursor = pnlCursor.createImage(intImageSize,intImageSize);
    gD_c = imgCursor.getGraphics();
    g_c = pnlCursor.getGraphics();
    pnlCursor.hide();

    Color bgColor = new Color(2, 2, 2, 0);
    gD_c.setColor(bgColor);
    gD_c.fillRect(0, 0, intImageOriginalSize, intImageOriginalSize);
    gD_c.drawImage(imgMap,
    0,0,
    intImageSize,intImageSize,
    ForeGroundTile*intImageSize,0,
    (ForeGroundTile+1)*intImageSize,intImageSize,
    null);

    Point hotspot = new Point((intImageSize/2),(intImageSize/2));
    pnlGraphics.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(imgCursor,hotspot,"tile"));
     
    Tim, Aug 14, 2003
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VG9tYXMgS2VwaWM=?=

    Changing DEFAULT cursor to WAIT cursor in ASP

    =?Utf-8?B?VG9tYXMgS2VwaWM=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,480
    Bruce Barker
    Apr 5, 2005
  2. Replies:
    2
    Views:
    542
    Adrienne
    Jun 30, 2005
  3. Replies:
    4
    Views:
    585
    Adrienne
    Jun 30, 2005
  4. invy
    Replies:
    4
    Views:
    511
    CBFalconer
    Dec 28, 2006
  5. dmaziuk
    Replies:
    3
    Views:
    775
    Chris Gonnerman
    Jan 25, 2011
Loading...

Share This Page