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 6072487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:09:57+00:00 2026-05-23T10:09:57+00:00

Below is a modified snippet from eclipse site to show what I’m talking about.

  • 0

Below is a modified snippet from eclipse site to show what I’m talking about. There are 2 performance issues.

1) Initially, it takes a number of seconds to display. If I increase the loop to 10000 it takes a long time (probably linear).

2) When you click a button it adds a widget to a panel and then has to lay out all the widgets in the scroller again. And this takes a number of seconds (too long).

Is there some way to accomplish these things I’m trying to do faster?

I’m trying to figure a way to show arbitrary items in a “list” type of view. My understanding is that the standard list widget shows strings only, so I assume I have to set up my own like this. Is there some other way?

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class Snippet188 {
    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        shell.setLayout(new FillLayout());
        final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        sc.setLayout(new FillLayout());
        final Composite c = new Composite(sc, SWT.NONE);
        RowLayout rl = new RowLayout(SWT.VERTICAL);
        rl.wrap = false;
        c.setLayout(rl);
        System.out.println(System.currentTimeMillis());
        for (int i = 0; i < 1000; i++) {
            final Composite item = new Composite(c, SWT.NONE);
            item.setLayout(new RowLayout(SWT.VERTICAL));
            Label l = new Label(item, SWT.NONE);
            l.setText("Label " + i);
            Button b = new Button(item, SWT.PUSH);
            b.setText("Button " + i);
            final int value = i;
            b.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    System.out.println("clicked: " + value);
                    Label newL = new Label(item, SWT.NONE);
                    newL.setText("new Label " + value);
                    item.pack();
                    c.pack();
                }
            });
        }
        System.out.println(System.currentTimeMillis());
        sc.setContent(c);
        sc.setExpandHorizontal(true);
        sc.setExpandVertical(true);
        sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        sc.setShowFocusedControl(true);

        shell.setSize(300, 500);
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) display.sleep();
        }
        display.dispose();
    }
}
  • 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-23T10:09:57+00:00Added an answer on May 23, 2026 at 10:09 am

    You can try to achieve the same using a single column Table together with a TableEditor to achieve the same. Take a look at this snippet that shows how to add another widget to a Table cell.

    This way you will avoid the creating as many Composites and layout overhead. Also you can use a virtual Table to create the resources only as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a got a code snippet below modified from http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpart.aspx : public class WebPartBla
In the code below I have changed show() to css() and modified the visibility.
I have tried using the below code modified from http://www.html5rocks.com/tutorials/file/dndfiles/ to read in a
The code below is modified from an O'Reilly Book - Learning PHP, MySQL, and
The example below throws an InvalidOperationException, Collection was modified; enumeration operation may not execute.
Below are lines from the c++ programming language template<class T > T sqrt(T );
Below is a stored procedure to check if there is a duplicate entry in
i've been modified the code like below <script type=text/javascript> function addtext() { var barCode
In the below code snippet can i replace char * to const char *
Below is my VHost (which is slightly modified to obscure some URLS): 1 NameVirtualHost

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.