|
|
|
|
|
|
Re: how to update the shell after invoke setSize()?? [message #454910 is a reply to message #454847] |
Mon, 02 May 2005 16:08 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
You are sleeping in the UI thread, you are not running in another
thread. asyncexec does not start a new thread, it runs your runnable in
the UI thread. Because you are sleeping in the UI thread, you are
locking up the UI for 2 seconds so that nothing happens during that time.
--
Thanks,
Rich Kulp
|
|
|
Re: how to update the shell after invoke setSize()?? [message #454916 is a reply to message #454910] |
Mon, 02 May 2005 20:11 |
bbskill Messages: 26 Registered: July 2009 |
Junior Member |
|
|
I am afraid that is wrong .
I use asyncexec only to ensure the non-UI thread can execute while the
shell is openning.
see this code ,this is the same as before ,but only adds
System.out.println("the size of the shell was "+ size);
Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(200,200);
display.asyncExec(new Runnable() {
public void run() {
while(true) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Point size = shell.getSize();
System.out.println("the size of the shell was "+ size);
shell.setSize(size.x+=50,size.y+=50);
}
}
});
shell.open();
while(!shell.isDisposed())
display.readAndDispatch();
display.dispose();
you will see after the shell is openned ,the size of the shell is
reported larger and larger ,but the actual size of the shell doesn't
change.that means setSize() doesn't work after the shell is
openned,except I use the setVisible(false) and setVisible(true) to
update the shell.
Rich Kulp wrote:
> You are sleeping in the UI thread, you are not running in another
> thread. asyncexec does not start a new thread, it runs your runnable in
> the UI thread. Because you are sleeping in the UI thread, you are
> locking up the UI for 2 seconds so that nothing happens during that time.
>
>
|
|
|
Re: how to update the shell after invoke setSize()?? [message #454922 is a reply to message #454916] |
Mon, 02 May 2005 18:25 |
Eclipse User |
|
|
|
Originally posted by: bob.objfac.com
It is obviously true that you are sleeping 2 seconds in the UI thread.
That's what asyncExec does - run something in the UI thread.
Bob Foster
bbskill wrote:
> I am afraid that is wrong .
> I use asyncexec only to ensure the non-UI thread can execute while the
> shell is openning.
> see this code ,this is the same as before ,but only adds
> System.out.println("the size of the shell was "+ size);
>
> Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setSize(200,200);
> display.asyncExec(new Runnable() {
> public void run() {
> while(true) {
> try {
> Thread.sleep(2000);
> } catch (InterruptedException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> Point size = shell.getSize();
> System.out.println("the size of the shell was "+ size);
> shell.setSize(size.x+=50,size.y+=50);
> }
> }
> });
> shell.open();
> while(!shell.isDisposed())
> display.readAndDispatch();
> display.dispose();
> you will see after the shell is openned ,the size of the shell is
> reported larger and larger ,but the actual size of the shell doesn't
> change.that means setSize() doesn't work after the shell is
> openned,except I use the setVisible(false) and setVisible(true) to
> update the shell.
>
> Rich Kulp wrote:
>
>> You are sleeping in the UI thread, you are not running in another
>> thread. asyncexec does not start a new thread, it runs your runnable
>> in the UI thread. Because you are sleeping in the UI thread, you are
>> locking up the UI for 2 seconds so that nothing happens during that time.
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03051 seconds