Eclipse插件开发4-SWT布局

import org.eclipse.swt.SWT;import org.eclipse.swt.layout.GridData;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Display;impo...
摘要由CSDN通过智能技术生成
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
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 GridData_GridLayoutTest2 {

	protected Shell shell;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			GridData_GridLayoutTest2 window = new GridData_GridLayoutTest2();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		GridLayout layout  = new GridLayout();
		layout.numColumns = 3;
		shell.setLayout(layout);
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");
		Button button1 = new Button(shell, SWT.PUSH);
		button1.setText("button1");
		GridData buttonGrid = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
		buttonGrid.heightHint = 100;
		buttonGrid.widthHint = 100;
		button1.setLayoutData(buttonGrid);

		Button button2 = new Button(shell, SWT.PUSH);
		button2.setText("button2");
		GridData button2data = new GridData(SWT.FILL,SWT.FILL,false,false,1,2);
		buttonGrid.heightHint = 100;
		buttonGrid.widthHint = 100;
		button2.setLayoutData(button2data);

		Button button3 = new Button(shell, SWT.PUSH);
		button3.setText("button3");
		GridData button3data = new GridData(GridData.FILL_BOTH);
		button3.setLayoutData(button3data);

		Button button4 = new Button(shell, SWT.PUSH);
		button4.setText("button4");
		GridData button4Grid = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
		button4Grid.heightHint = 100;
		button4Grid.widthHint = 100;
		button4.setLayoutData(button4Grid);
	 
	}

}

 

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.S
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值