Solved

Changing mouse cursor in applet

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

705 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