helloworld.java

来自「Eclipse从入门到精通源代码/第二篇 SWT_JFace篇(6-16章)」· Java 代码 · 共 26 行

JAVA
26
字号
package com.swtdesigner;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;

public class HelloWorld {
    public static void main(String[] args) {
        final Display display = Display.getDefault();
        final Shell shell = new Shell();
        shell.setSize(327, 253);
        shell.setText("SWT Application");
        //------------------新插入的界面核心代码------------------------
        Text text = new Text(shell, SWT.BORDER); //新建一个text对象
        text.setText("HelloWorld"); //给text文本框设置初始文字HelloWorld
        text.setBounds(88, 94, 100, 25); //设置文本框的位置和大小,(x轴坐标,y轴坐标,宽度,高度)
        //------------------END---------------------------------------------
        shell.layout();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    }
}

⌨️ 快捷键说明

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