myframe.java

来自「eclipse开发入门与项目实践」· Java 代码 · 共 29 行

JAVA
29
字号
package swtdesign;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.swtdesigner.SWTResourceManager;

public class MyFrame {

	public static void main(String[] args) {
		final Display display = Display.getDefault();
		final Shell shell = new Shell();
		shell.setSize(300, 150);
		shell.setText("SWT Application");
		shell.open();

		final Text text = new Text(shell, SWT.BORDER);
		text.setFont(SWTResourceManager.getFont("", 12, SWT.BOLD));
		text.setText("娆㈣繋浣犵殑鍒版潵锛屾劅鍙桽WT鐨勪笘鐣岋紒");
		text.setBounds(0, 0, 293, 25);

		final Button button = new Button(shell, SWT.NONE);
		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				text.setText("浣犲崟鍑讳簡寮

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?