0

我是 SWT 新手,我需要在 CTabItem 上任意设置控件位置。

我用过下面的代码,但是好像没有定位效果,只是把组件加到(0, 0)

Label userName = new Label(folder, SWT.NONE);
userName.setText("username");
userName.setBounds(10, 200, 200, 50);
item.setControl(userName);
4

1 回答 1

0

您需要将 LayoutManager 设置为folder,例如:

folder.setLayout(new GridLayout());

如果您希望为控件提供特定尺寸,请考虑为其提供 LayoutData,例如:

GridData gd = new GridData();
gd.height = 50;
userName.setLayoutData(gd);

我不确定item您的示例中有什么,但似乎没有必要。

于 2010-06-21T19:23:21.623 回答