SWT(JFace) 體驗之FontRegistry
package swt_jface.demo;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
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;
import org.eclipse.swt.widgets.Text;
public class FontRegistryExample {
Display display = new Display();
Shell shell = new Shell(display);
FontRegistry fontRegistry;
public FontRegistryExample() {
init();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private void init() {
shell.setLayout(new GridLayout(2, false));
fontRegistry = new FontRegistry(display);
fontRegistry.put("button-text", new FontData[]{new FontData("Arial", 9, SWT.BOLD)} );
fontRegistry.put("code", new FontData[]{new FontData("Courier New", 10, SWT.NORMAL)});
Text text = new Text(shell, SWT.MULTI | SWT.BORDER | SWT.WRAP);
text.setFont(fontRegistry.get("code"));
text.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
text.setText("public static void main() {\n\tSystem.out.println(\"Hello\"); \n}");
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
Button executeButton = new Button(shell, SWT.PUSH);
executeButton.setText("Execute");
executeButton.setFont(fontRegistry.get("button-text"));
Button cancelButton = new Button(shell, SWT.PUSH);
cancelButton.setText("Cancel");
cancelButton.setFont(fontRegistry.get("button-text"));
}
public static void main(String[] args) {
new FontRegistryExample();
}
}
上一篇:SWT(JFace) 打印功能
欄 目:Java編程
下一篇:SWT(JFace)體驗之StackLayout布局
本文標題:SWT(JFace) 體驗之FontRegistry
本文地址:http://mengdiqiu.com.cn/a1/Javabiancheng/8510.html
您可能感興趣的文章
- 01-10SWT(JFace)體驗之FormLayout布局
- 01-10SWT(JFace)體驗之RowLayout布局
- 01-10SWT JFace Bookmark 制作
- 01-10SWT(JFace)小制作 BugTracker
- 01-10SWT(JFace)體驗之StyledText類
- 01-10SWT(JFace)體驗之GridLayout布局
- 01-10SWT JFace 拖曳效果
- 01-10SWT(JFace)體驗之ApplicationWindow
- 01-10SWT(JFace)體驗之復(fù)制粘貼
- 01-10SWT(JFace)體驗之打開多個Form


閱讀排行
本欄相關(guān)
- 01-10Java咖啡館(1)——嘆咖啡
- 01-10JVM的垃圾回收機制詳解和調(diào)優(yōu)
- 01-10Java Socket編程(三) 服務(wù)器Sockets
- 01-10Java進階:Struts多模塊的技巧
- 01-10J2SE 1.5版本的新特性一覽
- 01-10Java Socket編程(一) Socket傳輸模式
- 01-10Java運行時多態(tài)性的實現(xiàn)
- 01-10Java Socket編程(二) Java面向連接的類
- 01-10Java Socket編程(四) 重復(fù)和并發(fā)服務(wù)
- 01-10Java經(jīng)驗點滴:處理沒有被捕獲的異常
隨機閱讀
- 04-02jquery與jsp,用jquery
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10C#中split用法實例總結(jié)
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 01-10delphi制作wav文件的方法
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文