Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to update the shell after invoke setSize()??
how to update the shell after invoke setSize()?? [message #454588] Mon, 25 April 2005 11:14 Go to next message
bbskill is currently offline bbskillFriend
Messages: 26
Registered: July 2009
Junior Member
hello all,
that is my question:
when I change the size of shell with the setSize() after it is opened,
how can I update the size of the shell immediately ??
Thanks for your help!!
Re: how to update the shell after invoke setSize()?? [message #454599 is a reply to message #454588] Mon, 25 April 2005 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Set the size before you open, and it will open at that size.


--
Thanks,
Rich Kulp
Re: how to update the shell after invoke setSize()?? [message #454603 is a reply to message #454588] Mon, 25 April 2005 14:30 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I don't understand the question. CAn you provide a small stand alone
snippet?

"bbskill" <bbkills@tom.com> wrote in message
news:d4ibai$kse$1@news.eclipse.org...
> hello all,
> that is my question:
> when I change the size of shell with the setSize() after it is opened,
> how can I update the size of the shell immediately ??
> Thanks for your help!!
Re: how to update the shell after invoke setSize()?? [message #454663 is a reply to message #454603] Tue, 26 April 2005 22:43 Go to previous messageGo to next message
bbskill is currently offline bbskillFriend
Messages: 26
Registered: July 2009
Junior Member
hello :
the snippet as show below:

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();
shell.setSize(size.x+=50,size.y+=50);
}
}
});
shell.open();
while(!shell.isDisposed())
display.readAndDispatch();
display.dispose();
In the same UI_Thread,for example a button ,if it invokes the setSize()
function of the shell ,the shell will change its size immediately .
But the shell won't change its size when another thread invokes its
setSize() function !
and another question : how to detect whether the shell is in focus ?
Thank you for your help !

Steve Northover wrote:
> I don't understand the question. CAn you provide a small stand alone
> snippet?
>
> "bbskill" <bbkills@tom.com> wrote in message
> news:d4ibai$kse$1@news.eclipse.org...
>
>>hello all,
>>that is my question:
>>when I change the size of shell with the setSize() after it is opened,
>>how can I update the size of the shell immediately ??
>>Thanks for your help!!
>
>
>
Re: how to update the shell after invoke setSize()?? [message #454665 is a reply to message #454663] Tue, 26 April 2005 21:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

You can't set the size from another thread. The size can only set on the
UI thread. If you try to do it from another a exception is thrown.


--
Thanks,
Rich Kulp
Re: how to update the shell after invoke setSize()?? [message #454847 is a reply to message #454663] Sun, 01 May 2005 19:17 Go to previous messageGo to next message
bbskill is currently offline bbskillFriend
Messages: 26
Registered: July 2009
Junior Member
can anyone give a help ?

bbskill wrote:
> hello :
> the snippet as show below:
>
> 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();
> shell.setSize(size.x+=50,size.y+=50);
> }
> }
> });
> shell.open();
> while(!shell.isDisposed())
> display.readAndDispatch();
> display.dispose();
> In the same UI_Thread,for example a button ,if it invokes the setSize()
> function of the shell ,the shell will change its size immediately .
> But the shell won't change its size when another thread invokes its
> setSize() function !
> and another question : how to detect whether the shell is in focus ?
> Thank you for your help !
>
> Steve Northover wrote:
>
>> I don't understand the question. CAn you provide a small stand alone
>> snippet?
>>
>> "bbskill" <bbkills@tom.com> wrote in message
>> news:d4ibai$kse$1@news.eclipse.org...
>>
>>> hello all,
>>> that is my question:
>>> when I change the size of shell with the setSize() after it is opened,
>>> how can I update the size of the shell immediately ??
>>> Thanks for your help!!
>>
>>
>>
>>
Re: how to update the shell after invoke setSize()?? [message #454910 is a reply to message #454847] Mon, 02 May 2005 16:08 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
bbskill is currently offline bbskillFriend
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 Go to previous message
Eclipse UserFriend
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.
>>
>>
Previous Topic:'passive' Table
Next Topic:IM user list like widget
Goto Forum:
  


Current Time: Thu Apr 25 21:03:38 GMT 2024

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

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

Back to the top