我是靠谱客的博主 单纯糖豆,最近开发中收集的这篇文章主要介绍SWT(JFace)体验之FillLayout布局,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

FillLayout布局

FillLayout是非常简单的一种布局方式,它会以同样大小对父组件中的子组件进行布局,这些子组件将以一行或一列的形式排列。一般来说,用户可以在任务栏、工具栏中放置FillLayout布局,通过FillLayout布局对子组件进行定位,也可以当子组件只有一个组件时,通过FillLayout布局填充整个父组件的空间。

FillLayout的风格

FillLayout布局中,可以把子组件按水平或垂直的方式进行排列,这些风格是当创建FillLayout实类时以参数形式指定的。

演示代码:

复制代码 代码如下:

package swt_jface.demo2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FillLayoutSample {

Display display = new Display();
Shell shell = new Shell(display);
public FillLayoutSample() {

FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
fillLayout.marginHeight = 5;
fillLayout.marginWidth = 5;
fillLayout.spacing = 1;

shell.setLayout(fillLayout);

Button button1 = new Button(shell, SWT.PUSH);
button1.setText("button1");

Button button2 = new Button(shell, SWT.PUSH);
button2.setText("button number 2");

Button button3 = new Button(shell, SWT.PUSH);
button3.setText("3");
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

public static void main(String[] args) {
new FillLayoutSample();
}
}

最后

以上就是单纯糖豆为你收集整理的SWT(JFace)体验之FillLayout布局的全部内容,希望文章能够帮你解决SWT(JFace)体验之FillLayout布局所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(171)

评论列表共有 0 条评论

立即
投稿
返回
顶部