Solved

Changing mouse cursor in applet

Posted on 1997-11-19
3
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
runtime exception 2 63
ejb entity bean example issue 2 40
Html Table Looping (part 2) 5 39
What is the use of Forwarding Class in java 1 51
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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.
Suggested Courses

739 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