[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Composite update problem

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@xxxxxxx> schrieb im Newsbeitrag 
news:d4qtug$fe9$1@xxxxxxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxx> wrote in message 
> news:d4qn8p$5n2$1@xxxxxxxxxxxxxxxxxxx
>> 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!
>>
>
>