grid.jvt

来自「SWT_designer安装软件」· JVT 代码 · 共 72 行

JVT
72
字号
import
org.eclipse.swt.SWT
org.eclipse.swt.layout.GridData
org.eclipse.swt.layout.GridLayout
org.eclipse.swt.widgets.Button
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Display
org.eclipse.swt.widgets.Group
org.eclipse.swt.widgets.Label
org.eclipse.swt.widgets.Shell
org.eclipse.swt.widgets.Text

method
	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell();
		final GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 3;
		shell.setLayout(gridLayout);
		shell.setText("GridLayout test");
		{
			final Label label = new Label(shell, SWT.NONE);
			final GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
			gridData.horizontalSpan = 3;
			label.setLayoutData(gridData);
			label.setText("label");
		}
		{
			final Text text = new Text(shell, SWT.BORDER);
			final GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
			gridData.horizontalSpan = 3;
			text.setLayoutData(gridData);
			text.setText("horizontalSpan = 3 Text");
		}
		{
			final Group group = new Group(shell, SWT.NONE);
			group.setText("Left group");
			group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
		}
		{
			final Composite composite = new Composite(shell, SWT.NONE);
			composite.setLayout(new GridLayout());
			composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
			{
				final Button button = new Button(composite, SWT.NONE);
				button.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_END));
				button.setText("button");
			}
			{
				final Button button = new Button(composite, SWT.NONE);
				button.setLayoutData(new GridData());
				button.setText("button");
			}
			{
				final Button button = new Button(composite, SWT.NONE);
				button.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_BEGINNING));
				button.setText("button");
			}
		}
		{
			final Group group = new Group(shell, SWT.NONE);
			group.setText("Right group");
			group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
		}
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}

⌨️ 快捷键说明

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