Solved

Changing mouse cursor in applet

Posted on 1997-11-19
3
324 Views
Last Modified: 2008-02-26
I need to change the mouse cursor into the hand-cursor if the user moves the mouse over a specific area of my applet. I want to do the same as a html link would do. Show the "hand-cursor" over a link to signialize click-me. Is this possible in Java? Thanks.
0
Comment
Question by:Duebel
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
russgold earned 80 total points
ID: 1230965
This is fairly straightforward in JDK 1.1, where you can use the setCursor() method to associate a cursor with a component. Java will automatically switch to that cursor when you move the mouse over the component.

Since you ask about applets, however, I suspect that you need a JDK 1.02 solution, which is a bit more elaborate. You need to find the Frame which encloses your component and explicitly set the cursor as needed in a mouse handler.

For an example, check out my applet (with source code) at:

http://www.netaxs.com/~russgold/java_samples/dragTest.html

If you move the mouse over a basketball, the cursor will change to a crosshair.  It will change to a hand when you click and drag a basketball to the hoop.

The code that does this is found in the DragSurface class.
0
 
LVL 4

Expert Comment

by:russgold
ID: 1230966
I should mention that, on Windows platforms, the hand cursor is an arrow pointing straight up; on Mac and Unix it is actually a hand.
0
 

Author Comment

by:Duebel
ID: 1230967
Thanks a lot
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now