ComboViewer Horizontal Layout [message #1417368] |
Fri, 05 September 2014 05:16  |
Eclipse User |
|
|
|
Hello,
i have a problem with a ComboViewer and the layout. The ComboViewer should be large as needed to show the hole content ? I don't want to set the width with the minSize, because the content length can change.
Example:
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class ComboViewerSnippet {
public static void main(String[] args) {
// get display.
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("ComboViewerSnippet");
shell.setSize(200, 200);
shell.setLayout(new FillLayout(SWT.HORIZONTAL));
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
new Label(composite, SWT.NONE).setText("Test");
ComboViewer viewer = new ComboViewer(composite);
GridDataFactory.fillDefaults().grab(true, false).applyTo(viewer.getControl());
viewer.add("Loooooooooooooooong Text");
viewer.add("890ß Text");
viewer.add("980ß Text");
viewer.getCombo().select(0);
new Label(shell, SWT.NONE).setText("New");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
Has anyone an idea?
Thanks
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05149 seconds