CTabFolder content display issue in combination with ScrolledComposite [message #1724013] |
Fri, 19 February 2016 19:41 |
Artem Portnoy Messages: 2 Registered: February 2016 |
Junior Member |
|
|
Hi,
I have a CTabFolder with 3 CTabItem each one of which contains a ScrolledComposite. The issue is that the content of the second and third tabs is invisible until the window is either resized or after the user repeatedly clicks through the tabs. Please help!
public class TestCTabFolder {
private CTabFolder tabFolder;
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Show CTabFolder");
createContents(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private void createContents(Shell shell) {
shell.setLayout(new GridLayout(1, true));
// Create the tabs
tabFolder = new CTabFolder(shell, SWT.TOP);
tabFolder.setBorderVisible(true);
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
tabFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tabFolder.getSelection().notifyListeners(SWT.SELECTED, new Event());
}
});
CTabItem firstTab = addTab("tab1");
addTab("tab2");
addTab("tab3");
tabFolder.setSelection(firstTab);
}
private CTabItem addTab(String title) {
CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
tabItem.setText(title);
final ScrolledComposite scrolledComp = new ScrolledComposite(tabFolder, SWT.V_SCROLL);
final Composite comp = new Composite(scrolledComp, SWT.NONE);
scrolledComp.setContent(comp);
comp.setLayout(new GridLayout(1, true));
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
for (int i = 0; i < 30; i++) {
Label label = new Label(comp, SWT.NONE);
label.setText(title + ": label" + i);
}
scrolledComp.setExpandVertical(true);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setMinSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tabItem.setControl(scrolledComp);
tabItem.addListener(SWT.SELECTED, new Listener() {
@Override
public void handleEvent(Event event) {
scrolledComp.layout(true);
}
});
return tabItem;
}
public static void main(String[] args) {
new TestCTabFolder().run();
}
}
Thanks,
Artem
|
|
|
|
Powered by
FUDForum. Page generated in 0.03253 seconds