SWT(JFace) 体验之FontRegistry
来源:本站原创|时间:2020-01-10|栏目:Java编程|点击: 次
复制代码 代码如下:
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
本文地址:https://www.xiuzhanwang.com/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)体验之复制粘贴
- 01-10SWT(JFace)体验之打开多个Form
阅读排行
本栏相关
- 01-10Java咖啡馆(1)——叹咖啡
- 01-10JVM的垃圾回收机制详解和调优
- 01-10Java Socket编程(三) 服务器Sockets
- 01-10Java进阶:Struts多模块的技巧
- 01-10J2SE 1.5版本的新特性一览
- 01-10Java Socket编程(一) Socket传输模式
- 01-10Java运行时多态性的实现
- 01-10Java Socket编程(二) Java面向连接的类
- 01-10Java Socket编程(四) 重复和并发服务
- 01-10Java经验点滴:处理没有被捕获的异常
随机阅读
- 04-02jquery与jsp,用jquery
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-10C#中split用法实例总结
- 01-11ajax实现页面的局部加载
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-10SublimeText编译C开发环境设置
- 01-10delphi制作wav文件的方法
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文