Set Controls with arbitrary positions on CTabItem

142 views Asked by At

I am new to SWT, and I need to set the controls positions arbitrary on CTabItem.

I've used the following code, but it seems that it had no positioning effect, it just add the component to (0, 0)

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

There are 1 answers

0
Paul Lammertsma On

You will need to set a LayoutManager to folder, e.g.:

folder.setLayout(new GridLayout());

If you wish to give the control a certain dimensions, consider giving it LayoutData, e.g.:

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

I'm not sure what item is in your example, but it doesn't seem to be necessary.