Is there a pattern for placing hourglasses on and off through GUI apps?
My actions are not necessarily near the code that created the button
someButton.addListener(actionListener);
I suppose I have to toggle the hour glass withing the action listener,
being careful to catch exceptions and turn it off?
Any alternatives?
thanks
Tim
First about one response
Venkatesh said:
Every Component has a method called setCursor function. U an use that
To set a cursor to hourglass, u can say setCursor(Cursor.WAIT_CURSOR)
-Venkatesh
What is he talking about?
Cursor.WAIT_CURSOR is int
Component doesnt' have method setCursor(int)
but it has method setCursor(Cursor).
Here isn't any standards.
If you need just show that program
is busy processing request it may look like
// --- set specific cursor ---
setCursor(?);
try{
// --- process
} catch(Exception ifYouWantOrNeed){
} finally{
// --- set default or previous cursor
setCursor(?);
}
in any actionPerformed and/or another event processing
methods.
You may want to read doc about
java.awt.Component#protected void processEvent(AWTEvent e)
or
java.awt.EventQueue#protected void dispatchEvent(AWTEvent e)
Also read about the Glass Pane
http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
Personally I prefer to cover (set Visible) my RootPaneContainer with
glass pane that have wait cursor set as default
if task can be long (also read about multi threading in Swing)