Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Default Cursor image

Posted on 1998-02-05
5
Medium Priority
?
160 Views
Last Modified: 2010-04-16
How do I change the cursor image (like to the pointing hand) with say a mouseEnter event?? Is there a function that does it??

0
Comment
Question by:jcorbin
5 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 300 total points
ID: 1232899
public void setCursor(int cursortype);

is a method in the class Frame in the package awt.

The arguments that can be given are:

Frame.DEFAULT_CURSOR
Frame.CROSSHAIR_CURSOR
Frame.TEXT_CURSOR
Frame.WAIT_CURSOR
Frame.SW_RESIZE_CURSOR
Frame.SE_RESIZE_CURSOR
Frame.NW_RESIZE_CURSOR
Frame.NE_RESIZE_CURSOR
Frame.N_RESIZE_CURSOR
Frame.S_RESIZE_CURSOR
Frame.W_RESIZE_CURSOR
Frame.E_RESIZE_CURSOR
Frame.HAND_CURSOR
Frame.MOVE_CURSOR
0
 

Expert Comment

by:xvincent
ID: 1232900
In java 1.1, there are api called setCursor() and getCursor().  They are defined in the class java.awt.Component, therefore all the classes extend from java.awt.Component can use the above 2 apis to handle the cursor matter.  The api using java.awt.Cursor as parameter and return value.  There are some defined cursor shapes in the class java.awt.Cursor.

In java 1.0, there are api called setCursor() and getCursor() as well, but they are defined under java.awt.Frame.  Therefore only the class extended from java.awt.Frame can use that api.  It introduced problem for a class extended from java.awt.Component, like Button, to change cursor shape.

However, we can use the api getParent() to find out the Frame castable container and then set the cursor.

e.g.
Frame getFrame(Component comp) {
  while(!(comp instanceof Frame) && comp != null) {
    comp = comp.getParent();
  }
  return (comp == null) ? null : comp;
}

0
 

Author Comment

by:jcorbin
ID: 1232901
So if I am using an Applet I am outta luck because there's no Frame to cast to, is that right??


0
 
LVL 16

Expert Comment

by:imladris
ID: 1232902
An applet certainly can have a frame. But it doesn't need to.
So, if you're in 1.0.2, and you don't have a frame,
there is no apparent solution.

0
 

Expert Comment

by:ethereal
ID: 3571872
Would the above solution work on a mouseOver, if I were using Java Script in Netscape?  I can change it quite easily if I'm in IE.

Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

876 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