您的位置:首页 > 编程语言 > Java开发

java swt TitleAreaDialog 添加滚动条

2012-01-10 11:03 323 查看
protected Control createDialogArea(Composite parent) {

Composite area = (Composite) super.createDialogArea(parent);

ScrolledComposite scrolledComposite = new ScrolledComposite(area, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);

GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);

gridData.heightHint = 205;//可调节大小,不可缺少

scrolledComposite.setLayoutData(gridData);

scrolledComposite.setExpandHorizontal(true);

scrolledComposite.setExpandVertical(true);

scrolledComposite.setAlwaysShowScrollBars(true);

Composite container = new Composite(scrolledComposite, SWT.NONE);

container.setLayout(new FillLayout(SWT.HORIZONTAL));

Composite composite = new Composite(container, SWT.NONE);

composite.setLayout(new GridLayout(2, false));

Label label = new Label(composite, SWT.NONE);

label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));

label.setText("New Label");

Button button = new Button(composite, SWT.NONE);

button.setText("New Button1");

Label label_1 = new Label(composite, SWT.NONE);

label_1.setText("New Label2");

Button button_1 = new Button(composite, SWT.NONE);

button_1.setText("New Button2");

Label label_2 = new Label(composite, SWT.NONE);

label_2.setText("New Label");

Button button_2 = new Button(composite, SWT.NONE);

button_2.setText("New Button3");

Label label_3 = new Label(composite, SWT.NONE);

label_3.setText("New Label");

Button button_3 = new Button(composite, SWT.NONE);

button_3.setText("New Button4");

Label label_5 = new Label(composite, SWT.NONE);

label_5.setText("New Label");

Button button_4 = new Button(composite, SWT.NONE);

button_4.setText("New Button5");

Label label_4 = new Label(composite, SWT.NONE);

label_4.setText("New Label");

Button button_5 = new Button(composite, SWT.NONE);

button_5.setText("6");

Label label_6 = new Label(composite, SWT.NONE);

label_6.setText("New Label");

Button button_6 = new Button(composite, SWT.NONE);

button_6.setText("New Button7");

Label label_7 = new Label(composite, SWT.NONE);

label_7.setText("New Label");

Button button_7 = new Button(composite, SWT.NONE);

button_7.setText("New Button8");

Label label_8 = new Label(composite, SWT.NONE);

label_8.setText("New Label");

Button button_8 = new Button(composite, SWT.NONE);

button_8.setText("New Button9");

scrolledComposite.setContent(container);

scrolledComposite.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));

return area;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: