Solved

Default Cursor image

Posted on 1998-02-05
5
156 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
[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
5 Comments
 
LVL 16

Accepted Solution

by:
imladris earned 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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…
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:
Suggested Courses

710 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