Using RowData Objects : RowLayout « SWT « Java Tutorial






  1. The corresponding layout data for the RowLayout class is the RowData class.
  2. RowData can specify the initial width and height of a control.
  3. Layout data objects should not be reused in SWT/JFace
Using RowData Objects
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;

public class RowLayoutRowData {
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);

    RowLayout rowLayout = new RowLayout();
    shell.setLayout(rowLayout);

    Button button1 = new Button(shell, SWT.PUSH);
    button1.setText("button1");

    List list = new List(shell, SWT.BORDER);
    list.add("item 1");
    list.add("item 2");
    list.add("item 3");
    list.setLayoutData(new RowData(100, 35));
    
    Button button2 = new Button(shell, SWT.PUSH);
    button2.setText("button #2");

    shell.setSize(450, 200);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}








17.99.RowLayout
17.99.1.Using RowLayoutUsing RowLayout
17.99.2.Using all default value from RowLayoutUsing all default value from RowLayout
17.99.3.RowLayout: align widgets in a rowRowLayout: align widgets in a row
17.99.4.RowLayout snippet: align widgets in a columnRowLayout snippet: align widgets in a column
17.99.5.RowLayout: fillRowLayout: fill
17.99.6.RowLayout: justifyRowLayout: justify
17.99.7.RowLayout: marginLeft, marginRight, marginTop, marginBottomRowLayout: marginLeft, marginRight, marginTop, marginBottom
17.99.8.pack: Specifies whether all controls should take their preferred sizepack: Specifies whether all controls should take their preferred size
17.99.9.RowLayout: spacingRowLayout: spacing
17.99.10.RowLayout: typeRowLayout: type
17.99.11.RowLayout: wrapRowLayout: wrap
17.99.12.Using RowData ObjectsUsing RowData Objects