Vertical Scrollbar for Eclipse GridData

馋奶兔 提交于 2020-02-04 01:07:51

问题


I have the following java code in an eclipse application:

import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.datatools.connectivity.oda.OdaException;

public void setupList(Composite parent, List items) throws OdaException {

GridData myGrid = new GridData(GridData.FILL_HORIZONTAL);
List myList = new List(parent, SWT.V_SCROLL);
myList.setLayoutData(myGrid);
myList.setItems(items);

}

In my program, the number of items exceeds the maximum height of the window, but no vertical scrollbar appears.

I thought that passing the SWT.V_SCROLL parameter to the list would create a vertical scrollbar, but it didn't work.

What am I missing to make the GridData's List have a vertical scrollbar?

Thanks.


回答1:


I figured it out. The following line needed to change:

GridData myGrid = new GridData(GridData.FILL_BOTH); // FILL_BOTH instead of FILL_HORIZONTAL


来源:https://stackoverflow.com/questions/14284864/vertical-scrollbar-for-eclipse-griddata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!