Title: RE: [JAVA2D] CURSOR question

Definitely go with what Jim said. Cursor drawing is a vey low-level hardware accelerated graphics operation that you should not try and implement yourself.

Cursor tip:
If you set the Cursor and notice that the cursor does not change until you move the mouse (cause it won't on most versions of Windows) call Toolkit.sync() and it'll refresh the cursor image on screen.

Jeff K

-----Original Message-----
From: Jim Bucher [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 1:02 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA2D] CURSOR question


Cursor drawing is done automatically. You just need to create a cursor and
then use the setCursor method of Component. I have done something similar.
Here is a code snippet.

// creates an image of a circle with a plus
BufferedImage cursorImage = new
BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB);
Graphics g = cursorImage.getGraphics();
g.setColor(Color.white);
g.drawOval(6,6,20,20); // the circle
g.fillRect(9,15,14,3);  // h-line of plus
g.fillRect(15,9,3,14); // v-line of plus
g.setColor(Color.black);
g.drawOval(7,7,20,20); // the circle
g.drawLine(10,16,22,16);
g.drawLine(16,10,16,22);
addVertexCursor = toolkit.createCustomCursor(cursorImage, new Point(16,16),
"addVertexCursor");
...
setCursor(addVertexCursor);


At 02:33 PM 5/15/01 -0500, Ted Hill wrote:
>Hello,
>
>In an image processing application, I want to use a round 'cursor'  and to
>be able to tell whether certain image features (points) are inside or
>outside of the 'cursor.'
>
>I'm thinking of using Ellipse2D as the cursor:
>
>     1. each time the mouse moves, redraw the circle centered at the
> MouseEvent's x,y
>
>     2. use Shape.contains(Point2D pt) to see whether certain points are
> within the circle
>
>     3. create an invisible cursor using a transparent gif so all you see
> is the circle
>
>
>Does anyone have suggestions for better ways to do this?
>
>Thanks,
>
>Ted Hill

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to