?? griddata1.java
字號:
/**
* @作者:陳剛
* @Email:glchengang@yeah.net
* @Blog:http://blog.csdn.net/glchengang
*/
package swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class GridData1 {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(327, 253);
shell.setText("SWT Application");
//------------------新插入的界面核心代碼------------------------
shell.setLayout(new GridLayout(2, false));//2列且makeColumnsEqualWidth =
// false
new Button(shell, SWT.NONE).setText("b1");
new Button(shell, SWT.NONE).setText("button2");
Button button = new Button(shell, SWT.NONE);
GridData gridData = new GridData();//定義一個GridData對象
gridData.horizontalSpan = 2;//讓button搶占兩個列的空間
button.setLayoutData(gridData);
button.setText("b3");
new Button(shell, SWT.NONE).setText("button4");
new Button(shell, SWT.NONE).setText("button5");
//------------------END---------------------------------------------
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -