如何设置SWT标签填充?
当我将文本分配给我的标签时,它们会非常紧密地包裹文本,有时会切断“p”、“y”等的下边缘。我想在文本和边框之间有一些填充。我使用 TableWrapLayout 作为父级 Composite
,使用 TableWrapData 作为 Labels
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
layout.bottomMargin = 10;
layout.topMargin = 10;
client.setLayout(layout);
Label label= toolkit.createLabel(client, "", SWT.NONE);
我们使用 FormToolkit 来实现一致的设计,恕我直言,这对边框绘制没有影响
When i assign text to my Labels
, they wrap around it very tightly, sometimes cutting the lower edges off 'p', 'y' and alike. I would like to have some padding between text and border. I am using a TableWrapLayout for the parent Composite
and TableWrapData for the Labels
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 2;
layout.bottomMargin = 10;
layout.topMargin = 10;
client.setLayout(layout);
Label label= toolkit.createLabel(client, "", SWT.NONE);
We are using the FormToolkit for consistent design, IMHO this has no influence on border painting
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(多年后回答,但仍然是答案......)
(Answer many years later, but still an answer...)
SWT 中的布局(例如GridLayout)和LayoutData(例如GridData)对象只能控制控件外部的间距(因此它们只能设置边距,而不能设置内边距)。为了更改控制端本身,您只能使用
setSize()
和setBound()
。Layout (such as GridLayout) and LayoutData (e.g. GridData) objects in SWT can only control spacing outside a control (so they may only set margins, not padding). In order to change control side itself you can only use
setSize()
andsetBound()
.引用我对类似问题的回答:
Quoting my answer to a similar question: