Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ExpandItem empty at first expand(Problem: if the expandItem is collapsed, its content is not visible on first expand)
ExpandItem empty at first expand [message #1728326] Sat, 02 April 2016 02:35 Go to next message
Andy Junius is currently offline Andy JuniusFriend
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
Re: ExpandItem empty at first expand [message #1738014 is a reply to message #1728326] Fri, 15 July 2016 05:38 Go to previous message
Dave Babcock is currently offline Dave BabcockFriend
Messages: 1
Registered: July 2016
Junior Member
I'm having the same problem, with a twist. If the contents of the ExpandItem is a Label, then I have the problem. If the contents of the ExpandItem is a Link, then that item is shown on the first expand, but still not the adjacent Label ExpandItems.

Comments? Suggestions?
Previous Topic:ExpandBar Tooltip
Next Topic:maven repo with all SWT versions?
Goto Forum:
  


Current Time: Wed Dec 13 17:00:06 GMT 2017

Powered by FUDForum. Page generated in 0.01557 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software