Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » [Eclipse Forms] Incorrect size computation with ColumnLayout in ScrolledForm
[Eclipse Forms] Incorrect size computation with ColumnLayout in ScrolledForm [message #1792867] Wed, 25 July 2018 09:06
Daniel Darvas is currently offline Daniel DarvasFriend
Messages: 10
Registered: July 2014
Junior Member

I use a ColumnLayout with flexible number of columns (between 1 and 3) in a ScrolledForm. It works fine, except for the vertical scrollbar of the ScrolledForm. It looks like no matter how many columns are used currently, the scrollbar is sized like there is a single column only.
Have a look at the attached screenshots, it will clarify the issue.

Here is a MWE that I used to obtain the screenshots.

package debugeditor;

import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.forms.widgets.*;

public class Debug {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		FormToolkit toolkit = new FormToolkit(display);
		ScrolledForm form = toolkit.createScrolledForm(shell);

		ColumnLayout layout = new ColumnLayout();
		layout.minNumColumns = 1;
		layout.maxNumColumns = 3;

		for (int i = 0; i < 15; i++) {
			createDummySection(toolkit, form.getBody(), i);

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())

	private static void createDummySection(FormToolkit toolkit, Composite parent, int n) {
		Section section = toolkit.createSection(parent,
				Section.DESCRIPTION | Section.TITLE_BAR | Section.EXPANDED | Section.TWISTIE);
		Composite sectionBody = toolkit.createComposite(section);
		sectionBody.setLayout(new GridLayout(1, true));
		section.setLayoutData(new ColumnLayoutData());

		for (int i = 0; i < 3; i++) {
			toolkit.createLabel(sectionBody, "LOREM IPSUM DOLOR SIT AMET -- Label " + n + " / " + i);

It seems to me that the ColumnLayout.computeSize() is always called with a relatively small wHint, thus it assumes that a single column layout will be used and it returns the size accordingly. However, when the ColumnLayout.layout() is called and the actual layout is performed, the layout() method will take the real size of its parent client area into account, thus it is possible to use a multi-column layout if the parent composite is wide enough.

Am I missing something in my code or is this a bug?

Previous Topic:[Oxygen] Errors in TargetPlatformState
Next Topic:Cheat sheet XML validation
Goto Forum:

Current Time: Thu Apr 18 17:30:52 GMT 2024

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

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

Back to the top