I have got:
private void createTab(){
TabItem mvTabItem = new TabItem( tabFolder, SWT.NONE );
mvTabItem.setText( TabHeader.modelviews.getTabHeaderName() );
Composite mvContainer = new Composite( tabFolder, SWT.V_SCROLL );
mvContainer.setLayout( new GridLayout(1, false) );
mvContainer.setLayoutData( new GridData(GridData.FILL, GridData.FILL, true, true) );
mvTabItem.setControl( mvContainer );
// Selection of model views
createSelectionGroup(mvContainer);
// other code, more groups created
}
which creates tab item, adds vertical scrollbar, but scrolling is not working. Why?
Inside createSelectionGroup(mvContainer)
there is a scrollbar as well. This one works fine, no org.eclipse.swt.custom.ScrolledComposite
was applied:
private void createSelectionGroup(Composite parent)
{
// Create group component.
Group grpMVselection = new Group(parent, SWT.SHADOW_IN);
grpMVselection.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
grpMVselection.setText(SelectionLabelStr);
grpMVselection.setLayout(new GridLayout(1, true));
// another code, added buttons, listeners
final SashForm sashForm = new SashForm(grpMVselection, SWT.VERTICAL | SWT.BORDER);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// srolling applied
selectionTree = new CheckboxTreeViewer(sashForm, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.HIDE_SELECTION);
selectionTree.getTree().setLayoutData( new GridData( SWT.BEGINNING, SWT.BEGINNING, true, true ) );
}
There are similar questions publicized, but I can not apply answers to my code. I did try:
change
Composite mvContainer
toScrolledComposite
, did not helpinsert
mvContainer
toScrolledComposite
, did not helpTabItem mvTabItem = new TabItem( tabFolder, SWT.NONE ); mvTabItem.setText( TabHeader.modelviews.getTabHeaderName() ); final ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.V_SCROLL ); sc.setExpandVertical(true); mvTabItem.setControl(sc); Composite mvContainer = new Composite( sc, SWT.NONE ); //mvContainer.setLayout(new GridLayout()); mvContainer.setLayout( new GridLayout(1, false) ); mvContainer.setLayoutData( new GridData(GridData.FILL, GridData.FILL, true, true) ); sc.setContent(mvContainer);
Do children need change some property? Thanks for any hint!!!
CodePudding user response:
You do need to use ScrolledComposite
for scrolling composites.
Something like:
final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
tabItem.setText("Tab");
final ScrolledComposite sc = new ScrolledComposite(tabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
tabItem.setControl(sc);
final Composite scrolledComp = new Composite(sc, SWT.NONE);
scrolledComp.setLayout(new GridLayout());
sc.setContent(scrolledComp);
// Example contents
for (int i = 1; i <= 100; i )
new Label(scrolledComp, SWT.LEAD).setText("Label " i);
sc.setMinSize(scrolledComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
TreeViewers such as CheckboxTreeViewer can do scrolling themselves, but Composites requite ScrolledComposite.