我已经得到了:
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
}
创建选项卡项,添加垂直滚动条,但是滚动不起作用。为什么?
在createSelectionGroup(mvContainer)
中也有一个滚动条。这个滚动条工作正常,没有应用org.eclipse.swt.custom.ScrolledComposite
:
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 ) );
}
有类似的问题公布,但我不能应用答案到我的代码。我尝试:
1.将Composite mvContainer
更改为ScrolledComposite
,没有帮助
1.将mvContainer
插入到ScrolledComposite
,没有帮助
TabItem 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);
孩子们需要改变一些属性吗?谢谢任何提示!!!
1条答案
按热度按时间7cwmlq891#
您确实需要使用
ScrolledComposite
来滚动复合图像。类似于:
CheckboxTreeViewer之类的TreeViewer可以自己滚动,但Composites需要ScrollledComposite。