⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridlayout1.java

📁 Eclipse从入门到精通源代码/第二篇 SWT_JFace篇(6-16章)
💻 JAVA
字号:
/**
 * @作者:陈刚
 * @Email:glchengang@yeah.net
 * @Blog:http://blog.csdn.net/glchengang
 */
package swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class GridLayout1 {
    public static void main(String[] args) {
        final Display display = Display.getDefault();
        final Shell shell = new Shell();
        shell.setSize(327, 253);
        shell.setText("SWT Application");
        //------------------新插入的界面核心代码------------------------

        GridLayout gridLayout = new GridLayout();//生成一个GridLayout对象
        shell.setLayout(gridLayout); //将gridLayout布局应用于shell面板
        //建立五个按钮。一个按钮占一列,由左由右排,一行排完后自动转到下一行
        new Button(shell, SWT.NONE).setText("b1");
        new Button(shell, SWT.NONE).setText("button2");
        new Button(shell, SWT.NONE).setText("b3");
        new Button(shell, SWT.NONE).setText("button4");
        new Button(shell, SWT.NONE).setText("button5");

        //------------------END---------------------------------------------
        shell.layout();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
    }
}

⌨️ 快捷键说明

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