Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

custom cursor in XOR mode

 
Amit Agarwal
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using a custom crosshair cursor generated with a gif file containing the image. Is it possible that the cursor be shown in XOR mode, as can be seen in many graphics applications. i.e. the cursor (which is white in color) draws itsself in black wherever there is a white area on the panel.
Thanks in Advance
Amit
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... Java doesn't support this behavior directly, as far as I know... but I think you could do it yourself. All you would have to do is set the "real" cursor to an invisible cursor, and draw the crosshairs on the frame yourself using XOR mode ( the Java Graphics object supports this... ), using a mouseListener to get the x and y coordinates of where it should be drawn.

Here's some code I was testing this concept on... hope it helps you out some...

( Note: "NoCursor.gif" is just a 16 x 16 transparent gif. )



-Nate
[This message has been edited by Nathan Pruett (edited June 28, 2001).]
 
Amit Agarwal
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nate,
Thanks for your help, but this will be difficult to implement in my application as my paint() method is very heavy, and i am looking forward to make minimum calls to it. If this method is used I will have to call the paint everytime the mouse moves to erase the previous cursor drawing.
Amit
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic