zachary zachary - 4 months ago 18
Java Question

How to make GridLayout row fill availible space?

I have a

. I have two rows. I want one row to take up 500 pixels. I want the other row to take up the rest of the space.

How can I do this?


That's not a property of the GridLayout, but of the contained widgets' layout data. Say your composite contains two widgets:

parent.setLayout( new GridLayout() );

Button upper = new Button( parent, SWT.PUSH );
GridData upperData = new GridData( SWT.FILL, SWT.TOP, true, false );
upperData.heightHint = 500;
upper.setLayoutData( upperData );

Button lower = new Button( parent, SWT.PUSH );
GridData lowerData = new GridData( SWT.FILL, SWT.FILL, true, true );
lower.setLayoutData( lowerData );