ExpandItem empty at first expand [message #1728326] |
Sat, 02 April 2016 02:35 |
Andy Junius Messages: 8 Registered: February 2014 |
Junior Member |
|
|
Hi all,
I'm doing my first steps with SWT (no Eclipse app, just SWT). Right now I'm stuck with a ExpandBar or rather with the ExpandItems in it. If the ExpandItem is collapsed to begin with, its content is not visible on first expand. Closing and expanding it again fixes the problem, the content gets visible. The cause: size of the control is set to (1, 1) the first time, after that to the correct size. The following code demonstrates my problem:
package info.junius.test;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.ExpandItem;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class ExpandBarTest {
public static void main ( String[] args ) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(400, 300);
shell.setLayout(new FillLayout());
ExpandBar expandBar = new ExpandBar(shell, SWT.NONE);
for (int i = 0; i < 3; i++) {
// content for expand bar
Label label = new Label(expandBar, SWT.BORDER);
label.setText("Some text on index " + i);
label.setSize(label.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// expand item
ExpandItem expandItem = new ExpandItem( expandBar, SWT.NONE);
expandItem.setControl(label);
expandItem.setText("Group " + i);
expandItem.setHeight(expandItem.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
// Problem: if the expandItem is collapsed, its content is not visible on first expand
// closing and expanding it again fixes the problem, the content gets visible
// cause: size is set to (1, 1) the first time, after that to the correct size
expandItem.setExpanded(false); // not visible after first expand if false
// if the expandItem is expanded, the contents are all there
}
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
I'm working on Linux (Xubuntu) that uses GTK+. I tried the code on a Windows box and it works fine there. My question: is there anything I can do to fix the problem? Or could this be a bug? If so, are there any workarounds?
Cheers,
Andreas
|
|
|
|
Powered by
FUDForum. Page generated in 0.03186 seconds