I trying to use XML codes to create SWT Widgets.
I want to store these widgets first before adding it into the GUI component, so I created a List for storage of these widgets using
List<Widget> widgets = new ArrayList<Widget>();
However, how do I create this widget without specifying it’s parent composite?
Widget newWidget = new Button(null,SWT.RADIO); // Argument cannot be null
In here, I do not want to add it to a parent composite yet, so I specify null, but I am not able to get through.
How can I create this Widget without adding to the parent composite (as I do not have a composite now)?
Well, as javadoc states,
IllegalArgumentExceptionis thrown whenparentargument is null. What you can do is place your widgets at some invisible composite, and then useorg.eclipse.swt.widgets.Control.setParent(Composite parent)to add them to different Composite.