SWT: scrollable area within a tab

Posted by DaveJohnston on Stack Overflow See other posts from Stack Overflow or by DaveJohnston
Published on 2010-03-21T13:12:23Z Indexed on 2010/03/21 15:41 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

I am trying to add a scrollable area to my tabbed window. So far I have a CTabFolder in a shell. I have added 5 CTabItems to it and everything works as expected.

On one of my CTabItems the contents are too big to fit on the screen so I would like to be able to scroll. The contents is a collection of Groups each containing various widgets.

So the CTabFolder is created as follows:

CTabFolder tabs = new CTabFolder(shell, SWT.BORDER);
tabs.setSimple(false);
tabs.setUnselectedImageVisible(false);
tabs.setUnselectedCloseVisible(false);
tabs.setMinimizeVisible(false);
tabs.setMaximizeVisible(false);

FormData tabsLayoutData = new FormData();
tabsLayoutData.top = new FormAttachment(0, 5);
tabsLayoutData.left = new FormAttachment(0, 5);
tabsLayoutData.bottom = new FormAttachment(92, 0);
tabsLayoutData.right = new FormAttachment(100, -5);
tabs.setLayoutData(tabsLayoutData);

Then the CTabItem:

CTabItem tab = new CTabItem(tabs, SWT.NONE);
tab.setText("Role");

Then the contents:

Composite tabArea = new Composite(tabs, SWT.V_SCROLL); tabArea.setLayout(new FormLayout()); tab.setControl(tabArea);

So the groups contained within the tab are created with tabArea as the parent and everything appears as you would expect. The problem is though that the vertical scroll bar is always present but doesn't seem to do anything. The contents are chopped off at the bottom of the tabArea composite.

Is there anything else I need to do to get the scrolling to work properly?

© Stack Overflow or respective owner

Related posts about java

Related posts about swt