rowlayout2.java

来自「SWTJFace篇项目源程序该项目包含 包含了Eclipse下构建swt的基本」· Java 代码 · 共 34 行

JAVA
34
字号
package cn.com.chengang.swt;

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

public class RowLayout2 {
	public static void main(String[] args) {
		final Display display = Display.getDefault();
		final Shell shell = new Shell();
		shell.setSize(327, 253);
		// ---------创建窗口中的其他界面组件-------------
		RowLayout layout = new RowLayout();// new RowLayout(SWT.VERTICAL)和layout.type等效
		layout.marginWidth = 20;// 左右边界宽度
		layout.marginHeight = 10;// 上下边界高度
		layout.spacing = 15;// 组件间隔宽度
		layout.type = SWT.VERTICAL;// 竖着排列
		shell.setLayout(layout);
		new Button(shell, SWT.NONE).setText("确定");
		new Button(shell, SWT.NONE).setText("取消");
		new Button(shell, SWT.NONE).setText("帮助");
		// -----------------END------------------------
		shell.layout();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

⌨️ 快捷键说明

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