📄 drawhelveticatext.java
字号:
package com.swtSample.graphics;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
/**
* This class demonstrates how to draw text
*/
public class DrawHelveticaText {
public void run() {
Display display = new Display();
final Shell shell = new Shell(display);
// Create the font
final Font font = new Font(display, "Helvetica", 18, SWT.NORMAL);
shell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent event) {
// Set the font
event.gc.setFont(font);
// Draw the text
event.gc.drawText("My Text", 0, 0);
}
});
shell.setText("Draw Helvetica Text");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
font.dispose();
display.dispose();
}
public static void main(String[] args) {
new DrawHelveticaText().run();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -