How would you go about displaying huge amount of rows in SWT table? Huge is something above 20K rows, 20 columns. Don\'t ask me why I need to show that much data, it\'s not the
SWT can do that for you. When you use the SWT.VIRTUAL style flag, items are only created when scrolled into view. Here's how to do it:
Here's a code snippet:
public static void main( String[] args ) {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new FillLayout() );
final Table table = new Table( shell, SWT.VIRTUAL );
table.setItemCount( 10000 );
table.addListener( SWT.SetData, new Listener() {
public void handleEvent( Event event ) {
TableItem item = (TableItem)event.item;
item.setText( "Item " + table.indexOf( item ) );
}
} );
shell.setSize( 300, 500 );
shell.open();
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() ) {
display.sleep();
}
}
display.dispose();
}