1
나는 5 열의 gridlayout를 갖는 합성물을 가지고 있으며 일부에는 버튼이 포함되어 있습니다. 이제 다른 컨트롤을 에 GridLayout의 특정 위치에 추가 할 수 있습니까? 예를 들어, 하나의 TextField를 Button3 대신에 세 번째 열의 첫 번째 행에 추가하고 Button 3이 button7 이후의 마지막 행으로 이동해야합니다. GridLayout에서 모든 유형의 동적 위치 지정이 가능합니까?격자 레이아웃 동적으로 구성 요소 위치 지정
package zrcp;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class LayoutExample {
protected Shell shell;
/**
* Launch the application.
*
* @param args
*/
public static void main(String[] args) {
try {
LayoutExample window = new LayoutExample();
window.open();
}
catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
shell.setLayout(new GridLayout(5, false));
Button btnNewButton = new Button(shell, SWT.NONE);
btnNewButton.setText("Button1");
Button btnNewButton_1 = new Button(shell, SWT.NONE);
btnNewButton_1.setText("Button2");
Button btnNewButton_2 = new Button(shell, SWT.NONE);
btnNewButton_2.setText("Button3");
Button btnNewButton_3 = new Button(shell, SWT.NONE);
btnNewButton_3.setText("Button4");
Button btnNewButton_4 = new Button(shell, SWT.NONE);
btnNewButton_4.setText("Button5");
Button btnNewButton_5 = new Button(shell, SWT.NONE);
btnNewButton_5.setText("Button6");
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
Button btnNewButton_6 = new Button(shell, SWT.NONE);
btnNewButton_6.setText("Button7");
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
}
}