Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Waiting cursor "best practice"(How to use the waiting cursor in the best way ?)
Waiting cursor "best practice" [message #1016644] Thu, 07 March 2013 04:05 Go to next message
Eclipse UserFriend
Hi,

In my project I define two methods to set the mouse cursor to wait or default (arrow) one, as needed:

	private Cursor waitCursor;
	private Cursor arrowCursor;

	/**
	 * Set cursor to wait cursor
	 */
	public void setCursorToWait() {
		shell.setEnabled(false);
		if (waitCursor == null) {
			waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
	        }
		shell.setCursor(waitCursor);
	}

	/**
	 * Set cursor to default cursor
	 */
	public void setCursorToDefault() {
		if (arrowCursor == null) {
			arrowCursor = new Cursor(display, SWT.CURSOR_ARROW);
	        }
		shell.setCursor(arrowCursor);
		shell.setEnabled(true);
	}


As you can see, I not only change the cursor but also disable the Shell to prevent the user from clicking while the program is busy with a "long" task.
But I've just found out that the call to the setEnabled method of the Shell class causes a focus lost event from my current widget, which generates problems in some cases, notably when the current widget has a FocusListener.

My questions are:
> Is it necessary to disable the shell ?
> Is this the best way to set a waiting indicator ?

Thanks !


Re: Waiting cursor "best practice" [message #1017141 is a reply to message #1016644] Sat, 09 March 2013 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Why do not use an BusyIndicator?

// Show a busy indicator while the runnable is executed
BusyIndicator.showWhile(display, runnable); 
Re: Waiting cursor "best practice" [message #1017680 is a reply to message #1017141] Tue, 12 March 2013 06:14 Go to previous message
Eclipse UserFriend
Ok thanks I will try this
Previous Topic:SWT Graphics and Controls
Next Topic:Problem using focus listener
Goto Forum:
  


Current Time: Wed Jul 23 07:18:41 EDT 2025

Powered by FUDForum. Page generated in 0.04861 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top