I am using
org.eclipse.swt.widgets.List to add some items dynamically.
However the size of each string is larger than the default width given by the
How do I recompute the size of the list each time I add a new
String into the
Sorry for the naivety of the question, still a novice to SWT.
This is how I have created it:
Group parentGrp = new Group(threeColComposite,SWT.NONE);
parentGrp.setText("Interfaces Present in Selected jar");
myList = new List(parentGrp, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
myList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
I haven't used a separate layout for the
list as it was the only child of the parent group. Is it wrong if a layout hasn't been used?
@Baz: I have used the snippet from your answer here from the
I think the best way is to create your won Custom List (check e.g. http://www.snip2code.com/Snippet/11489/Custom-SWT-List-Box to create such a list) and then manage the events directly inside here
The Layout class and its subclasses provide that resizing behavior, albeit indirectly. The layout caches the original size of the list and uses that size even after you add more (and longer) items to the list. The fix is to tell the layout to layout a particular control and its children after flushing its cache (all one layout method). The widget/control you pass in is depends on how many widgets around your list need to be resized becase the list is resized.
Of course, the layout you use must be the same layout that laid out the widgets in the first place.