作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用组框来改进我的 GUI。但是,当将组件添加到Group
时,它们会移动到框的中心并且不再保持对齐。如何让每个按钮和文本移动到左边距。
代码
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") );
最佳答案
按钮左对齐,但您已指定在对齐完成之前向按钮左侧留出 300 像素的边距。
为Group
或Composite
布局指定的边距值可设置控件内的边距。
关于java - 如何将组组件左对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37575760/
我是一名优秀的程序员,十分优秀!