【问题标题】:How to remove the spacing between rows in a GridLayout composite?如何删除 GridLayout 组合中的行之间的间距?
【发布时间】:2023-04-10 14:01:01
【问题描述】:

这些只是示例代码。我创建了一个 GridLayout 组合并删除了边距。但是行之间仍然有空格。

Composite composite = new Composite(shell, SWT.NONE);
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.marginWidth = 0;
gl_composite.marginHeight = 0;
composite.setLayout(gl_composite);

Composite composite_1 = new Composite(composite, SWT.BORDER);
GridData gd_composite_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_composite_1.heightHint = 52;
gd_composite_1.widthHint = 802;
composite_1.setLayoutData(gd_composite_1);
composite_1.setLayout(new GridLayout(1, false));

Composite composite_2 = new Composite(composite, SWT.BORDER);
GridData gd_composite_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_composite_2.widthHint = 803;
composite_2.setLayoutData(gd_composite_2);

我需要行之间没有任何空格。复合材料是有边界的,因为我需要在下面有一条线。我是 SWT 的新手,所以..

谢谢!!

【问题讨论】:

    标签: java swt grid-layout


    【解决方案1】:

    GridLayoutverticalSpacing 字段设置行间距,所以:

    gl_composite.verticalSpacing = 0;
    

    使用horizontalSpacing 作为列间距。

    这两个值的默认值都是5

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-08
      • 2015-10-01
      • 2016-09-10
      • 1970-01-01
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 2020-02-26
      相关资源
      最近更新 更多