Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » freezing swt gui
freezing swt gui [message #499731] Mon, 23 November 2009 21:21 Go to next message
larsk is currently offline larskFriend
Messages: 22
Registered: October 2009
Location: Sweden
Junior Member
Is there a way to "freeze" the update of the gui while I am making some changes and then after a while make the gui to update again? Is there maybe a way so I can make the program so I have to update the gui manually by running some function?
I hope that someone understands what I want to do.
Re: freezing swt gui [message #499942 is a reply to message #499731] Tue, 24 November 2009 14:48 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I think Control.setRedraw() is what you want here. If not then please
follow up.

Grant


<larsk7@gmail.com> wrote in message news:heeuc4$e5s$1@build.eclipse.org...
> Is there a way to "freeze" the update of the gui while I am making some
changes and then after a while make the gui to update again? Is there maybe
a way so I can make the program so I have to update the gui manually by
running some function?
> I hope that someone understands what I want to do.
Re: freezing swt gui [message #500866 is a reply to message #499942] Sun, 29 November 2009 21:39 Go to previous messageGo to next message
larsk is currently offline larskFriend
Messages: 22
Registered: October 2009
Location: Sweden
Junior Member
Grant Gayed wrote on Tue, 24 November 2009 15:48
I think Control.setRedraw() is what you want here. If not then please
follow up.

Grant


Thanks for your reply!
I tested .setRedraw() but my gui is still changing when setRedraw is set to false.
In my application I set the setRedraw on a shell to false and then I dispose all the composites and labels on the shell. Then the app waits for some seconds and then I put some new composites and labels on the shell. But I don't want the gui to redraw/update/change until all the new composites and labels is put on the shell.
Is this the right way to go? Is it going to work with setRedraw when i dispose the composites and labels?
Re: freezing swt gui [message #501023 is a reply to message #500866] Mon, 30 November 2009 17:16 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I've looked into this a bit closer, and it appears that this case is not
currently working on Cocoa (it does work for me on win32 and gtk). I assume
you're using Cocoa? If so then this may not be supportable there (see the
"Note...hint" comment in setRedraw()'s javadoc). However it would not hurt
to log a report for this with swt to be investigated (
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT ).

However if you're not on Cocoa then this should work. Does the snippet
below work for you? And if so, can you modify it to more closely resemble
your case and show the problem?

public static void main (String [] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
shell.setLayout(new GridLayout());
Composite composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new FillLayout());
final Composite topComposite = composite;
composite = new Composite(composite, SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite, SWT.BORDER);
composite.setLayout(new GridLayout());
Button button1 = new Button(composite, SWT.PUSH);
button1.setText("Button 1");
Label label1 = new Label(composite, SWT.NONE);
label1.setText("Label 1");
shell.open();
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("shell.setRedraw(false);");
shell.setRedraw(false);
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("dispose the top Composite");
topComposite.dispose();
display.timerExec(2000, new Runnable() {
public void run() {
System.out.println("create some composites and
label2 and button2");
Composite composite = new Composite(shell,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new GridLayout());
new Label(composite, SWT.NONE).setText("Label
2");
composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new FillLayout());
composite = new Composite(composite,
SWT.BORDER);
composite.setLayout(new GridLayout());
new Button(composite, SWT.PUSH).setText("Button
2");
shell.layout();
display.timerExec(2000, new Runnable() {
public void run() {

System.out.println("shell.setRedraw(true);");
shell.setRedraw(true);
}
});
}
});
}
});
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant


"larsk" <larsk7@gmail.com> wrote in message
news:heuplr$mu2$1@build.eclipse.org...
> Grant Gayed wrote on Tue, 24 November 2009 15:48
> > I think Control.setRedraw() is what you want here. If not then please
> > follow up.
> >
> > Grant
>
>
> Thanks for your reply!
> I tested .setRedraw() but my gui is still changing when setRedraw is set
to false.
> In my application I set the setRedraw on a shell to false and then I
dispose all the composites and labels on the shell. Then the app waits for
some seconds and then I put some new composites and labels on the shell. But
I don't want the gui to redraw/update/change until all the new composites
and labels is put on the shell.
> Is this the right way to go? Is it going to work with setRedraw when i
dispose the composites and labels?
Re: freezing swt gui [message #501036 is a reply to message #501023] Mon, 30 November 2009 18:46 Go to previous messageGo to next message
larsk is currently offline larskFriend
Messages: 22
Registered: October 2009
Location: Sweden
Junior Member
Thanks for your help testing!
Yes, I am working with cocoa. To bad that it doesn't work. Is there another way to do this that works under cocoa?

Grant Gayed wrote on Mon, 30 November 2009 18:16
I've looked into this a bit closer, and it appears that this case is not
currently working on Cocoa (it does work for me on win32 and gtk). I assume
you're using Cocoa? If so then this may not be supportable there (see the
"Note...hint" comment in setRedraw()'s javadoc). However it would not hurt
to log a report for this with swt to be investigated (
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT ).
Re: freezing swt gui [message #501260 is a reply to message #501036] Tue, 01 December 2009 16:53 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Perhaps you could use a StackLayout to first lay out your new set of
controls on a Composite that's not the top control (therefore not visible),
and then set this Composite to be the top control once all of its children
are there and ready to be shown? (then dispose() the no-longer-on-top
Composite with the old set of Controls now that it's no longer visible).

Grant


"larsk" <larsk7@gmail.com> wrote in message
news:hf13ul$gi4$1@build.eclipse.org...
> Thanks for your help testing!
> Yes, I am working with cocoa. To bad that it doesn't work. Is there
another way to do this that works under cocoa?
>
> Grant Gayed wrote on Mon, 30 November 2009 18:16
> > I've looked into this a bit closer, and it appears that this case is not
> > currently working on Cocoa (it does work for me on win32 and gtk). I
assume
> > you're using Cocoa? If so then this may not be supportable there (see
the
> > "Note...hint" comment in setRedraw()'s javadoc). However it would not
hurt
> > to log a report for this with swt to be investigated (
> > https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform
&component=SWT ).
>
Re: freezing swt gui [message #501574 is a reply to message #501260] Wed, 02 December 2009 20:34 Go to previous message
larsk is currently offline larskFriend
Messages: 22
Registered: October 2009
Location: Sweden
Junior Member
Thanks for all help!
I have written a bug report to eclipse.
But I will also test your suggestion to create a new composite and then dispose the old one.

Grant Gayed wrote on Tue, 01 December 2009 17:53
Perhaps you could use a StackLayout to first lay out your new set of
controls on a Composite that's not the top control (therefore not visible),
and then set this Composite to be the top control once all of its children
are there and ready to be shown? (then dispose() the no-longer-on-top
Composite with the old set of Controls now that it's no longer visible).

Grant

Previous Topic:Is there a practical limit to the number of columns in a Table?
Next Topic:Get the TableEditors objects hosted in a TableItem
Goto Forum:
  


Current Time: Sat Apr 20 04:02:07 GMT 2024

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

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

Back to the top