Specify order/location of swt widgets in a composite object? -


i create widgets before inserting them swt composite parent. understand parent specified in constructor when child created:

composite container = new composite(parent, swt.null); gridlayout layout = new gridlayout(); container.setlayout(layout); layout.numcolumns = 3; layout.verticalspacing = 9; ... // create child @ first row leftmost location label labelconfigurator = new label(container, swt.null); labelconfigurator.settext(title); 

is possible somehow separate creation of widgets insertion/placement parent container?

no, there isn't. there's little bit of explanation here.

depending on want, factory might you; in past i've used this:

public interface viewerfactory {      text gettext(composite parent);      contentviewer getlistviewer(composite parent);      label getlabel(composite parent);  } 

with implementation

private final class viewerfactoryimpl implements viewerfactory {     @ override     public label getlabel ( composite parent ) {         return new label ( parent , swt.none ) ;     }      @ override     public contentviewer getlistviewer ( composite parent ) {         return new listviewer ( parent , swt.v_scroll | swt.border | swt.multi ) ;     }      @ override     public text gettext ( composite parent ) {         return new text ( parent , swt.border ) ;     }  } 

...which has helped me abstract away widget-building of code. when write unit test, mock factory interface.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -