Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Default Cursor image

Posted on 1998-02-05
5
Medium Priority
?
158 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 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

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 This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.
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 …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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