Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 763133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:30:42+00:00 2026-05-14T16:30:42+00:00

How would you go about displaying huge amount of rows in SWT table? Huge

  • 0

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 point. The point is how to make it work as fast as possible so that end user won’t get bored waiting. Each row displays an instance of some object, columns are its properties (some). I thought to use JFace content/label provider pattern, but afraid it will be even slower than hitting the table directly with the data. This is how it goes:

    Display.getDefault().asyncExec(new Runnable() {
       public void run() {
           List<MyObject> objects = model.getViewData();
           for(MyObject object: objects){
           TableItem item = new TableItem(table, SWT.NULL);
           item.setImage(0, img1);
           item.setBackground(color1);
               item.setText(0, object.getProperty0());
               item.setText(1, object.getProperty1());
               item.setText(2, object.getProperty2());
               ..... 
            }
       });

Drawing 20k records on my computer takes about 20 sec.
The biggest performance problem I’ve seen in Windows are caused by incredible amount of native windowing messages sent by SWT when new table item created and populated with text. I’ve found great workaround for this – hide table before populating, and then show it when done. Just calling table.setVisible(false) before the loop and table.setVisible(true) after the loop does wonders – the speed goes up six-seven times!

I’d like to speed it up even more.
What would you suggest ? Also, I wonder how this trick hiding the widget would work on non-windows implementations of SWT (aka Linux) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:30:43+00:00Added an answer on May 14, 2026 at 4:30 pm

    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:

    1. Create the table with style SWT.VIRTUAL
    2. Set the row count using Table#setItemCount()
    3. Add a SWT.SetData Listener that fills the TableItems on demand.

    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();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how would go about displaying five images in a row using
How would I go about displaying tweets that contain a certain hashtag using the
How would I go about displaying a tooltip when the user hover overs some
How would I go about displaying a tooltip when the user hover overs some
given a url that references an asmx how would i go about displaying all
I'm a bit confused about displaying data from a MySQL database. I would like
How would I go about displaying the default Google Maps controls when the user
What is the best way to go about displaying an html table with text
I was wondering how I would go about displaying the most common values in
How would I go about displaying the active to time that you can assign

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.