Solved

Changing mouse cursor in applet

Posted on 1997-11-19
3
327 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

830 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