Solved

Default Cursor image

Posted on 1998-02-05
5
152 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now