gpt4 book ai didi

java - 如何将组组件左对齐

转载 作者:行者123 更新时间:2023-12-01 09:51:23 25 4
gpt4 key购买 nike

我想使用组框来改进我的 GUI。但是,当将组件添加到Group时,它们会移动到框的中心并且不再保持对齐。如何让每个按钮和文本移动到左边距。 Group Box with centered elements

代码

GridLayout layout = new GridLayout(1, true);
layout.marginWidth = 300;
Group group = new Group(this, SWT.SHADOW_OUT);
group.setText("Open file locations");
group.setLayout(layout);

Button optionOne = new Button(group, SWT.CHECK | SWT.LEFT);
optionOne.setText(AppMessages.msg("Open file A") );

Button optionTwo = new Button(group, SWT.LEFT | SWT.CHECK);
optionTwo.setText(AppMessages.msg("Open file B") );

Need Space between two groups

最佳答案

按钮左对齐,但您已指定在对齐完成之前向按钮左侧留出 300 像素的边距。

GroupComposite 布局指定的边距值可设置控件内的边距。

关于java - 如何将组组件左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37575760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com