Community
Participate
Working Groups
When setting the text of a CCombo when there is not enough space for the text, the text still will not be painted when ther IS enough space. This only goes wrong under Windows Classic mode. Themed mode doesn't has this behaviour. I've added a snippit based on Snippt39 that demonstrates the problem. A window with combo is created, and after 5 seconds it's filled. The window is initially created with a small size, so the combo is not big enough to hold the text. If the boolean FAIL is set to false the window is created with a size that's big enough to hold the text. import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CCombo; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class Snippet39 { public static boolean FAIL = true; public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); GridLayout layout = new GridLayout(); layout.numColumns = 2; shell.setLayout(layout); new Text(shell, SWT.None); // To have something in place since the window has a minimum width final CCombo combo = new CCombo(shell, SWT.READ_ONLY); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("Item selected"); }; }); Thread job = new Thread() { @Override public void run() { // Wait 5 seconds try { Thread.sleep(5 * 1000); } catch (InterruptedException e) { } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { // Update the combo for (int i = 0; i < 5; i++) { combo.add("item" + i); } combo.setText("item0"); // And make the window bigger shell.setSize(300, 200); } }); } }; job.start(); if (FAIL) { shell.setSize(120, 200); } else shell.setSize(300, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
I have found a workaround though: when setting the combo text BEFORE setting the items, then the drawing goes ok: .... public void run() { combo.setText("item0"); // Update the combo for (int i = 0; i < 5; i++) { combo.add("item" + i); } // And make the window bigger shell.setSize(300, 200); } ...
The workaround doesn't work completely, since now the selected item isn't set.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.