Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Composite update problem
Composite update problem [message #454776] Thu, 28 April 2005 13:04 Go to next message
Eclipse UserFriend
Originally posted by: mek.mekistory.de

Hello everybody,

i have a composite_mother and inside that a toolbar (with two toolitems) and
another composite_child. When I press one of the toolitems, the
composite_child changes its content. But I can only see that when I resize
the window of the application.

What I've tried so far:

composite_child.layout()
composite_mother.layout()
shell.layout
shell.update
composite_mother.pack()
composite_child.pack()

But without success...

Thanks for any help!
Re: Composite update problem [message #454778 is a reply to message #454776] Thu, 28 April 2005 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: elbucho.gmx.de

That's very close to my problem with tables in a rich client application.
Only minimizing/restoring or maximizing of my view causes the table to be
shown correctly after a change has happened. Seems like it is a problem with
all SWT widgets, or should I say feature ? I made the same
layout/update/pack try, but also without success.

Any hints would help me, too.

Thanks,
Roland


"Marco Kohns" <mek@mekistory.de> wrote in message
news:d4qn8p$5n2$1@news.eclipse.org...
> Hello everybody,
>
> i have a composite_mother and inside that a toolbar (with two toolitems)
and
> another composite_child. When I press one of the toolitems, the
> composite_child changes its content. But I can only see that when I resize
> the window of the application.
>
> What I've tried so far:
>
> composite_child.layout()
> composite_mother.layout()
> shell.layout
> shell.update
> composite_mother.pack()
> composite_child.pack()
>
> But without success...
>
> Thanks for any help!
>
>
Re: Composite update problem [message #454783 is a reply to message #454776] Thu, 28 April 2005 14:58 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
If you are using 3.1, the following should work for you:

shell.layout(composite_child.getChildren());

If you know exactly which children have changed to can also do:

shell.layout(new Control[] {child1, child2, child5});

If you are not in 3.1, you need to know a bit about the parents between the
shell and composite_mother. If there is a parent that does not change size,
then the chain of layouts trigerred by shell.layout() will stop at the first
parent that does not resize. For example, if you have a parent that is in a
FillLayout, the only time that parent will change size is when its parent
gets bigger - it will not resize just because one of its children changed
its preferred size. If you have identified any parents like that in the
parent heirarchy of composite_child, then you must call layout() on that
parent.

For example:


public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell (display);
FillLayout layout = new FillLayout();
layout.marginWidth = layout.marginHeight = 5;
shell.setLayout(layout);

final Composite c1 = new Composite(shell, SWT.BORDER);
c1.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
layout = new FillLayout();
layout.marginWidth = layout.marginHeight = 5;
c1.setLayout(layout);

final Composite c2 = new Composite(c1, SWT.BORDER);
c2.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
c2.setLayout(new GridLayout(2, false));

Composite c3 = new Composite(c2, SWT.BORDER);
c3.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
c3.setLayout(new GridLayout(2, false));
for (int i = 0; i < 10; i++) {
Button b = new Button(c3, SWT.PUSH);
b.setText("c3 "+i);
}

final Composite c4 = new Composite(c2, SWT.BORDER);
c4.setBackground(display.getSystemColor(SWT.COLOR_RED));
c4.setLayout(new GridLayout(5, false));
Button b = new Button(c4, SWT.PUSH);
b.setText("CLICK HERE");
b.addListener(SWT.Selection, new Listener() {
int index = 0;
public void handleEvent(Event e) {
Button b = new Button(c4, SWT.PUSH);
b.setText("c4 "+index++);
// In 3.1, you can do:
//shell.layout(new Control[] {b});

// In 3.0 you must do the following (also works in
3.1)
c2.layout();
c4.layout();
// both are needed
// c2.layout is required if red area needs to grow.
// c4.layout is needed because sometimes c4 does not
change size
// (add buttons to existing row) but the new button
still need to
// be displayed

// Note: calling shell.layout() or c1.layout() has
no effect
// here because the children in the FillLayout do
not change size.

}
});
shell.setSize(400, 400);
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}



"Marco Kohns" <mek@mekistory.de> wrote in message
news:d4qn8p$5n2$1@news.eclipse.org...
> Hello everybody,
>
> i have a composite_mother and inside that a toolbar (with two toolitems)
> and another composite_child. When I press one of the toolitems, the
> composite_child changes its content. But I can only see that when I resize
> the window of the application.
>
> What I've tried so far:
>
> composite_child.layout()
> composite_mother.layout()
> shell.layout
> shell.update
> composite_mother.pack()
> composite_child.pack()
>
> But without success...
>
> Thanks for any help!
>
Re: Composite update problem [message #454795 is a reply to message #454783] Thu, 28 April 2005 23:49 Go to previous message
Eclipse UserFriend
Originally posted by: mek.mekistory.de

Hey that works, I'm using 3.1 !!!

parent.layout(composite_child.getChildren());

You're brilliant !!!

Thank you very much !!!

This newsgroup is great and you're even greater !!!


"Veronika Irvine" <veronika_irvine@oti.com> schrieb im Newsbeitrag
news:d4qtug$fe9$1@news.eclipse.org...
> If you are using 3.1, the following should work for you:
>
> shell.layout(composite_child.getChildren());
>
> If you know exactly which children have changed to can also do:
>
> shell.layout(new Control[] {child1, child2, child5});
>
> If you are not in 3.1, you need to know a bit about the parents between
> the shell and composite_mother. If there is a parent that does not change
> size, then the chain of layouts trigerred by shell.layout() will stop at
> the first parent that does not resize. For example, if you have a parent
> that is in a FillLayout, the only time that parent will change size is
> when its parent gets bigger - it will not resize just because one of its
> children changed its preferred size. If you have identified any parents
> like that in the parent heirarchy of composite_child, then you must call
> layout() on that parent.
>
> For example:
>
>
> public static void main (String [] args) {
> Display display = new Display ();
> final Shell shell = new Shell (display);
> FillLayout layout = new FillLayout();
> layout.marginWidth = layout.marginHeight = 5;
> shell.setLayout(layout);
>
> final Composite c1 = new Composite(shell, SWT.BORDER);
> c1.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
> layout = new FillLayout();
> layout.marginWidth = layout.marginHeight = 5;
> c1.setLayout(layout);
>
> final Composite c2 = new Composite(c1, SWT.BORDER);
> c2.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
> c2.setLayout(new GridLayout(2, false));
>
> Composite c3 = new Composite(c2, SWT.BORDER);
> c3.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
> c3.setLayout(new GridLayout(2, false));
> for (int i = 0; i < 10; i++) {
> Button b = new Button(c3, SWT.PUSH);
> b.setText("c3 "+i);
> }
>
> final Composite c4 = new Composite(c2, SWT.BORDER);
> c4.setBackground(display.getSystemColor(SWT.COLOR_RED));
> c4.setLayout(new GridLayout(5, false));
> Button b = new Button(c4, SWT.PUSH);
> b.setText("CLICK HERE");
> b.addListener(SWT.Selection, new Listener() {
> int index = 0;
> public void handleEvent(Event e) {
> Button b = new Button(c4, SWT.PUSH);
> b.setText("c4 "+index++);
> // In 3.1, you can do:
> //shell.layout(new Control[] {b});
>
> // In 3.0 you must do the following (also works in
> 3.1)
> c2.layout();
> c4.layout();
> // both are needed
> // c2.layout is required if red area needs to grow.
> // c4.layout is needed because sometimes c4 does
> not change size
> // (add buttons to existing row) but the new button
> still need to
> // be displayed
>
> // Note: calling shell.layout() or c1.layout() has
> no effect
> // here because the children in the FillLayout do
> not change size.
>
> }
> });
> shell.setSize(400, 400);
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
>
>
>
> "Marco Kohns" <mek@mekistory.de> wrote in message
> news:d4qn8p$5n2$1@news.eclipse.org...
>> Hello everybody,
>>
>> i have a composite_mother and inside that a toolbar (with two toolitems)
>> and another composite_child. When I press one of the toolitems, the
>> composite_child changes its content. But I can only see that when I
>> resize the window of the application.
>>
>> What I've tried so far:
>>
>> composite_child.layout()
>> composite_mother.layout()
>> shell.layout
>> shell.update
>> composite_mother.pack()
>> composite_child.pack()
>>
>> But without success...
>>
>> Thanks for any help!
>>
>
>
Previous Topic:Tiff compression in image?
Next Topic:JFace TitleAreaDialog
Goto Forum:
  


Current Time: Tue Apr 16 13:49:49 GMT 2024

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

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

Back to the top