|
|
|
Re: Hourglass! [message #458843 is a reply to message #458841] |
Fri, 22 July 2005 13:01 |
Eclipse User |
|
|
|
Originally posted by: pijnmar.home.nl
Something like this?
Cursor cursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(cursor);
....
shell.setCursor(null);
|
|
|
Re: Hourglass! [message #458844 is a reply to message #458841] |
Fri, 22 July 2005 14:29 |
Robert Bacs Messages: 165 Registered: July 2009 |
Senior Member |
|
|
Hi,
The runnable which is taken as argument is executed in the same thread,
that is in the GUI thread.
Below is a snippet:
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* @author Robert Bacs
*/
public class BusyIndicatorTest {
public static void main(String[] args) {
final Display display = new Display();
final Thread thread = Thread.currentThread();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
System.out.println("Thread1: " + Thread.currentThread());
shell.pack();
shell.open();
shell.layout();
BusyIndicator.showWhile(display, new Runnable(){
public void run() {
if (thread == Thread.currentThread()){
System.out.println("Same thread !!!");
}
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
"Mohit" <mohit.jhawar@gmail.com> wrote in message
news:50a85abd60643189e29c40933b4ff551$1@www.eclipse.org...
> It takes Runnable as an argument however, I m not spawning any new thread.
> How do i get access to current thread?
> forgive me for my naivete.
>
> Thanks,
> Mohit
> Robert Bacs wrote:
>
>
> > BusyIndicator.showWhile(...);
>
> > It's in the org.eclipse.swt.custom package
>
> > Regards,
> > Boby
>
>
> > "Mohit" <mohit.jhawar@gmail.com> wrote in message
> > news:6eb7ef2fb763d883618ba32611879a6a$1@www.eclipse.org...
> >> Hi,
> >> Can somebody please throw some light on how do I implement an hourglass
to
> >> indicate of wait, when my application takes long time to fetch result
or
> >> something else.
> >>
> >> Thanks,
> >> Mohit
> >>
>
|
|
|
Re: Hourglass! [message #458845 is a reply to message #458841] |
Fri, 22 July 2005 14:30 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Runnables are not new threads. They are simply packaged methods. They
give you an interface to call into them using the run method. They don't
have to be on a separate thread.
showWhile() simply calls your runnable.run(). It does not need another
thread.
Mohit wrote:
> It takes Runnable as an argument however, I m not spawning any new
> thread. How do i get access to current thread?
> forgive me for my naivete.
>
> Thanks,
> Mohit
> Robert Bacs wrote:
>
>
>> BusyIndicator.showWhile(...);
>
>
>> It's in the org.eclipse.swt.custom package
>
>
>> Regards,
>> Boby
>
>
>
>> "Mohit" <mohit.jhawar@gmail.com> wrote in message
>> news:6eb7ef2fb763d883618ba32611879a6a$1@www.eclipse.org...
>>
>>> Hi,
>>> Can somebody please throw some light on how do I implement an
>>> hourglass to
>>> indicate of wait, when my application takes long time to fetch result or
>>> something else.
>>>
>>> Thanks,
>>> Mohit
>>>
>
--
Thanks,
Rich Kulp
|
|
|
|
Powered by
FUDForum. Page generated in 0.03991 seconds