Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 SWT 新手,我需要在 CTabItem 上任意设置控件位置。
我用过下面的代码,但是好像没有定位效果,只是把组件加到(0, 0)
Label userName = new Label(folder, SWT.NONE); userName.setText("username"); userName.setBounds(10, 200, 200, 50); item.setControl(userName);
您需要将 LayoutManager 设置为folder,例如:
folder
folder.setLayout(new GridLayout());
如果您希望为控件提供特定尺寸,请考虑为其提供 LayoutData,例如:
GridData gd = new GridData(); gd.height = 50; userName.setLayoutData(gd);
我不确定item您的示例中有什么,但似乎没有必要。
item