Hallo,
ich habe ein Frage zum GridLayout im SWT.
Folgender Code bricht meine Frage aufs wesentliche runter:
Wie schaffe ich es, dass im rechten Child-Composite die Elemente auf Höhe der ersten Zeile des linken child-Composite sind. (sobald ich die Zeile
einkommentiere ist das der Fall, ich habe aber in meine Programm eben unterschiedliche Anzahl von Reihen im linken und rechten Composite.
verticalSpan hab ich schon versucht, hat nix gebracht.
Danke vorab
StarSheriff
ich habe ein Frage zum GridLayout im SWT.
Folgender Code bricht meine Frage aufs wesentliche runter:
Java:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class SwtLayoutExample
{
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new SwtLayoutExample().createShell(display);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
}
private Shell createShell(Display display)
{
final Shell shell = new Shell(display);
shell.setText("GridLayout");
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
shell.setLayout(gridLayout);
Composite parent = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(2, true);
parent.setLayout(gl);
Composite child1 = new Composite(parent, SWT.NONE);
GridLayout gl1 = new GridLayout(2, true);
child1.setLayout(gl1);
new Label(child1, SWT.NONE).setText("LinkeSeite");
new Label(child1, SWT.NONE).setText("RechteSeite");
new Label(child1, SWT.NONE).setText("zweiteZeile");
Composite child2 = new Composite(parent, SWT.NONE);
GridLayout gl2 = new GridLayout(3, true);
child2.setLayout(gl2);
Label l1 = new Label(child2, SWT.NONE);
l1.setText("Links");
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER, SWT.BEGINNING, false, true);
l1.setLayoutData(data);
new Label(child2, SWT.NONE).setText("Mitte");
new Label(child2, SWT.NONE).setText("Rechts");
// new Label(child2, SWT.NONE).setText("zweite Zeile links");
return shell;
}
}
Wie schaffe ich es, dass im rechten Child-Composite die Elemente auf Höhe der ersten Zeile des linken child-Composite sind. (sobald ich die Zeile
Java:
// new Label(child2, SWT.NONE).setText("zweite Zeile links");
verticalSpan hab ich schon versucht, hat nix gebracht.
Danke vorab
StarSheriff