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

📄 formlayoutsample.java

📁 Eclipse RCP应用系统开发方法与实战源代码
💻 JAVA
字号:
package rcpbook.swtjface.sample;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class FormLayoutSample {
	public static void main(String[] args) {
		final Display display = Display.getDefault();
		final Shell shell = new Shell();
		shell.setSize(240, 200);
		shell.setText("FormLayout布局");
		FormLayout layout = new FormLayout();
		layout.marginTop = 5;
		layout.marginLeft = 5;
		layout.marginRight = 5;
		shell.setLayout(layout);

		Button button1 = new Button(shell, SWT.PUSH);
		button1.setText("按钮1");
		FormData formData = new FormData();
		formData.height = 40;
		formData.right = new FormAttachment(100, -100);
		formData.left = new FormAttachment(0, 10);
		formData.top = new FormAttachment(1, 10, 0);
		button1.setLayoutData(formData);

		Button button2 = new Button(shell, SWT.PUSH);
		button2.setText("按钮2");
		formData = new FormData();
		formData.height = 60;
		formData.width = 90;
		button2.setLayoutData(formData);
		formData.top = new FormAttachment(button1, 5, SWT.BOTTOM);
		formData.left = new FormAttachment(button1, -10, SWT.RIGHT);

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}

⌨️ 快捷键说明

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