The goal that I wanted to learn about the child addition is to lay out children (adding LayoutData for example GridData ) when a child is added to a child element that is laid out using a specific layout (for example, GridLayout ).
Since it is impossible to add layouts to the add-on, check their layout each time the widget is resized:
this.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { layoutChildren(); } }); } private void layoutChildren(){ for(Control child:getChildren()){ if(child.getLayoutData() == null){ child.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); } } } public void addToGroup(Composite child){ child.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); }
source share