?? styledtext1.java
字號:
package cn.com.chengang.swt;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class StyledText1 {
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(200, 100);
// ---------創建窗口中的其他界面組件-------------
shell.setLayout(new FillLayout());
StyledText text = new StyledText(shell, SWT.WRAP | SWT.BORDER);
text.setText("書籍:Eclipse從入門到精通");
StyleRange styleRange = new StyleRange();// 創建一個式樣
styleRange.start = 3;// 開始字符(中文和字母都算一個字符)
styleRange.length = "Eclipse".length();// 應用的字符數
styleRange.fontStyle = SWT.BOLD;// 粗體
styleRange.foreground = display.getSystemColor(SWT.COLOR_BLUE);// 前景色:藍
styleRange.background = display.getSystemColor(SWT.COLOR_RED);// 背景色:紅
styleRange.underline = true;// 下劃線
styleRange.strikeout = true;// 刪除線
text.setStyleRange(styleRange);
// -----------------END------------------------
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -