?? helloworld.java
字號:
package com.swtdesigner;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class HelloWorld {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(236, 164);
shell.setText("SWT Application");
//定義一個文本框,樣式風格為帶邊框
final Text text = new Text(shell, SWT.BORDER);
/**
* 對文本框進行在窗體上定位,通用模式為:
* setBounds(int x,int y,int width,int hight)
* x表示橫坐標;y表示縱坐標;width表示文本框長度;
* hight表示文本框的高度
*/
text.setBounds(36, 37, 84, 21);
//定義一個按鈕
final Button button = new Button(shell, SWT.NONE);
button.setText("button");
button.setBounds(134, 38, 57, 20);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -