This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes custom cursor in XOR mode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "custom cursor in XOR mode" Watch "custom cursor in XOR mode" New topic
Author

custom cursor in XOR mode

Amit Agarwal
Ranch Hand

Joined: May 09, 2001
Posts: 92
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

Joined: Oct 18, 2000
Posts: 4121

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).]


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Amit Agarwal
Ranch Hand

Joined: May 09, 2001
Posts: 92
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: custom cursor in XOR mode