This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hide mouse  RSS feed

 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to, when the mouse enters a Panel, have the Mouse disappear (presumably to be replaced by an Image at the mouse coords?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, all you need to do is create a new cursor using a transparent image (see the java.awt.Toolkit createCursor() method for this) and then just call setCursor() on the Panel, passing in your new clear cursor.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a thousand thanks
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what's s'durned invalid about my image? I'm not seeing anything, so i assume it's an "invalid image", as i was warned about by the specs of Toolkit. any ideas? it's just a little marker with a transparent background, it's 24x24.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of image is it (GIF? PNG?), and how are you loading the image in your program? Make sure the path and file name are correct (and watch out for spaces if you're using Windows), the JVM doesn't throw an exception if you load an image that it thinks doesn't exist... it just creates an empty image.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GIF... i know the image/filename are otherwise correct, i tested it by just drawing the image in a random place.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know then... I made a 24x24 GIF image with a transparent background and it showed up fine as a cursor.

Can you post the code of where you are creating the cursor?
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heh... case closed... sorry to have wasted your time
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!