Solved

Default Cursor image

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

832 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