Click to See Complete Forum and Search --> : setCursor()


George Dinwiddie
February 12th, 1999, 10:49 AM
Using JDK 1.2, I'm finding that I can successfully set the cursor for a Swing component, but not for a Swing Container. Looking at the Component.setCursor() api, I read



"public void setCursor(Cursor cursor)



Sets the cursor image to the specified cursor. This cursor image is displayed when the contains method for this component returns true for the current cursor location. Setting the cursor of a Container causes that cursor to be displayed within all of the container's subcomponents, except for any subcomponents that are using a non-default cursor."



I'm finding that, for the cursor to be displayed in the container's subcomponents, I have to override setCursor in the container and have it call setCursor in the subcomponent.



Am I missing something?




java.awt.Component.setCursor() documentation

Zafir Anjum
February 12th, 1999, 10:56 PM
There are various problems with setCursor() but the problem you are seeing is

probably the documented behaviour. Most Swing containers are entirely covered

by child components. Since the child component covers the container completely,

any call to setCurson() on the container does not have any effect.


If you are trying to change the curson of a JFrame, there's an article on this

site that covers that. See under 'Swing' category.

George Dinwiddie
February 15th, 1999, 07:59 AM
Well, as I read the documentation, it seems to say that calling setCursor()

on a container will pass it along to all components. That seems more

efficient to me than having to call it directly on all components in the

container.


I'm not sure I see the message you mention. Are you talking about

http://www.codeguru.com/java/bbs/55.shtml ?


Is this the message?

Valerie Bradley
June 25th, 1999, 04:50 PM
I believe the article you want is:

http://www.codeguru.com/java/articles/188.shtml

(You see, I'm trying to find an answer to the same question.) :)

Good luck, and happy coding!


=================================================
Valerie L. Bradley
Software Engineer
Intel Corporation

* All opinions expressed are mine and not those of my employer.

Roopa
March 28th, 2001, 01:45 AM
Thanks for the information .I just needed it .