Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

Mouse Cursor with hourglass and pointer

Thread view: 
decalod85 - 29 Sep 2005 19:56 GMT
I have looked high and low and cannot find a way to duplicate
the Windows mouse cursor with the pointer and hourglass in
a Swing GUI.  I just don't see it anywhere in there.

There are times in our application when we want to indicate to the
user that the GUI is busy, but that they can still click on things.

How do other folks do this?
Vova Reznik - 29 Sep 2005 20:07 GMT
To change cursor check out
    java.awt.Cursor
    java.awt.Component.setCursor(Cursor)

Changing cursor wont block GUI from Mouse/Key/Input events.

To block events you should use glass pane.

> I have looked high and low and cannot find a way to duplicate
> the Windows mouse cursor with the pointer and hourglass in
[quoted text clipped - 4 lines]
>
> How do other folks do this?
decalod85 - 30 Sep 2005 13:18 GMT
> To change cursor check out
>      java.awt.Cursor
>      java.awt.Component.setCursor(Cursor)

That would work great, but swing doesn't include a cursor of the
shape that I want.

> Changing cursor wont block GUI from Mouse/Key/Input events.
>
> To block events you should use glass pane.

Actually, I have found glass pane completely inadequate for blocking
events.  I intercept the events in the event queue.  That works much
better.
Vova Reznik - 30 Sep 2005 15:02 GMT
> Actually, I have found glass pane completely inadequate for blocking
> events.  I intercept the events in the event queue.  That works much
> better.
Glass Pane is just Component. If you wont add listeners (with empty
methods) to it - it wont block anything, cos it wont know. :)

Something like this:
getGlassPane().addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
         // --- EMPTY ---
         // --- Nothing to perform ---
    }
});
Roedy Green - 01 Oct 2005 02:03 GMT
>Glass Pane is just Component. If you wont add listeners (with empty
>methods) to it - it wont block anything, cos it wont know. :)

Adding an empty listener is the same as having no listener at all.

If you want to suppress events you have to hook in at a lower level
and use event.consume.  See http://mindprod.com/jgloss/event11.html

Some years ago I poked around quite a bit in the Java 1.0 and 1.1
event loops. One thing I found distressing was all the cloning of
events. Instead of making them immutable, Java clones them and lets
you ruin them.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Vova Reznik - 03 Oct 2005 15:24 GMT
> Adding an empty listener is the same as having no listener at all.

Not really. If glass pane will not have listeners
then any events will go through glass pane to covered component.
But if glass pane will have listeners - glass pane will consume them all.
Roedy Green - 03 Oct 2005 17:33 GMT
>Not really. If glass pane will not have listeners
>then any events will go through glass pane to covered component.
>But if glass pane will have listeners - glass pane will consume them all.
I did not know that
~ Johnny Carson

I thought GlassPanes were just for doing overlays.  I never would have
suspected they would behave like 1.0 events.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas A. Russ - 30 Sep 2005 17:20 GMT
> > To change cursor check out
> >      java.awt.Cursor
> >      java.awt.Component.setCursor(Cursor)
>
> That would work great, but swing doesn't include a cursor of the
> shape that I want.

There's always  java.awt.Toolkit.createCustomCursor

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Roedy Green - 30 Sep 2005 07:15 GMT
>I have looked high and low and cannot find a way to duplicate
>the Windows mouse cursor with the pointer and hourglass in
[quoted text clipped - 4 lines]
>
>How do other folks do this?

see http://mindprod.com/jgloss/cursor.html

If worse comes to worse, you can roll you own.  I doubt anyone would
shoot you if you did a PSP camera snap of your favourite mouse cursor.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Oliver Wong - 30 Sep 2005 22:05 GMT
>>I have looked high and low and cannot find a way to duplicate
>>the Windows mouse cursor with the pointer and hourglass in
>>a Swing GUI.  I just don't see it anywhere in there.
>
> If worse comes to worse, you can roll you own.  I doubt anyone would
> shoot you if you did a PSP camera snap of your favourite mouse cursor.

   The copyright holder of the cursor might.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.