Project: SWT
Bug 102794 GridLayout has change behaviour between 3.0.2 and 3.1
Reported: 2005-07-05 17:56:18 | Status: resolved fixed

Running the following problem on 3.0.2 and 3.1 shows a difference in behaviour: public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite editor = new Composite(sc1, SWT.SHADOW_NONE); sc1.setContent(editor); sc1.setLayout(new FillLayout()); GridLayout layout = new GridLayout(); layout.numColumns = 6; layout.makeColumnsEqualWidth = true; editor.setLayout(layout); Label boxLabel = new Label(editor, SWT.NONE); boxLabel.setText("My label"); Text textBox = new Text(editor, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); textBox.setText("Some text for the text box\nAlso with a new line"); // do layout bits GridData labelData = new GridData(SWT.RIGHT, SWT.TOP, false, false); boxLabel.setLayoutData(labelData); GridData textBoxData = new GridData(SWT.FILL, SWT.CENTER, true, false, 5, 1); textBoxData.widthHint = 400; textBox.setLayoutData(textBoxData); sc1.setExpandHorizontal(true); sc1.setExpandVertical(true); sc1.setMinSize(editor.computeSize(SWT.DEFAULT, SWT.DEFAULT)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } Basically on 3.0.2 the window that appears has a label of about 80 pixels wide and a textbox of 400 pixels wide. With 3.1 the label is about 400 pixels wide, with the text box being about 2000 pixels wide. This appears to be a combination of the text box spanning 5 columns and the use of layout.makeColumnsEqualWidth = true; Turning off makeColumnsEqualWidth helps but it means that the real app this if from ends up looking untidy. Using minimumWidth instead of widthHint doesn't help. Commenting out the minimumWidth line helps, but the form ends up being wider than I'd like. The effect I'm trying to achieve is that labels are 1 column wide then text boxes are either 2 or 5 columns wide (so some rows get two labels and text boxes) The scrolled composite is needed because in the real app the forms are actually within a TabItem, so I need the ability to scroll.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java