美文网首页扣丁学堂Java培训
扣丁学堂Java视频之SWT(JFace)体验之FillLayo

扣丁学堂Java视频之SWT(JFace)体验之FillLayo

作者: 994d14631d16 | 来源:发表于2018-06-26 11:03 被阅读1次

本篇文章小编和大家分享扣丁学堂Java视频教程SWT(JFace)体验之FillLayout布局,FillLayout是非常简单的一种布局方式,它会以同样大小对父组件中的子组件进行布局,这些子组件将以一行或一列的形式排列。

扣丁学堂Java视频

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();

}

}

以上就是扣丁学堂Java在线学习小编给大家分享的用三角函数在canvas上画虚线的方法,希望对小伙伴们有所帮助。想要了解更多内容的小伙伴可以登录扣丁学堂官网咨询,扣丁学堂是专业的Java培训机构,扣丁学堂不仅有专业的老师和与时俱进的课程体系,还有大量的Java在线视频供学员观看学习,喜欢Java的小伙伴快快行动吧。

相关文章

网友评论

    本文标题:扣丁学堂Java视频之SWT(JFace)体验之FillLayo

    本文链接:https://www.haomeiwen.com/subject/sdppyftx.html