您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在SWT / JFace RCP应用程序中填充大表

在SWT / JFace RCP应用程序中填充大表

SWT可以为您做到这一点。当您使用SWT.VIRTUAL样式标志时,仅当滚动到视图时才创建项目。方法如下:

这是一个代码片段:

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();
}
其他 2022/1/1 18:33:29 有470人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶