[英]SWT List display line numbers
如何在SWT列表中显示行号? 我确实参考了一些显示StyledText行号的帖子,但它对我没有帮助。
提前致谢!
作为替代方案,您可以使用具有2列而没有标题的Table
:
public static void main(String[] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
Table table = new Table(shell, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.setLinesVisible(false);
new TableColumn(table, SWT.RIGHT);
new TableColumn(table, SWT.NONE);
for (int row = 0; row < 20; row++)
{
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, row + "");
item.setText(1, "Item " + row);
}
for(int col = 0; col < table.getColumnCount(); col++)
{
table.getColumn(col).pack();
}
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
看起来像这样:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.