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

  • Home
  • SEARCH
  • 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 8490933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:16:13+00:00 2026-06-10T22:16:13+00:00

private ArrayList<PrinterProfile> printersList = null; private ArrayList<PrinterProfile> printers = null; … void Method() {

  • 0
private ArrayList<PrinterProfile> printersList = null;
private ArrayList<PrinterProfile> printers = null;    

...

void Method() {
    ...
    printers = (ArrayList<PrinterProfile>) listOp.getPrinters();
    printersList.setListData(printers.toArray(new PrinterProfile[0]));
}

setListData is only for JList but I am using SWT and ArrayList

  • 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-06-10T22:16:14+00:00Added an answer on June 10, 2026 at 10:16 pm

    I think what you are searching for is the SWT List. You can use it like this:

    import java.util.ArrayList;
    import java.util.Arrays;
    
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.List;
    import org.eclipse.swt.widgets.Listener;
    import org.eclipse.swt.widgets.Shell;
    
    public class MiniExample {
    
        public static void main(String[] args) {
            Display display = Display.getDefault();
            final Shell shell = new Shell(display);
            shell.setLayout(new GridLayout(1, false));
    
            // Fill your ArrayList with its content
            ArrayList<String> printer = new ArrayList<String>();
            printer.add("Epson");
            printer.add("Canon");
            printer.add("HP");
    
            final List printerList = new List(shell, SWT.MULTI | SWT.BORDER);
    
            // Fill the ArrayList into the SWT List
            for(String print : printer)
                printerList.add(print);
    
            // Print selection
            printerList.addListener(SWT.Selection, new Listener() {
                @Override
                public void handleEvent(Event arg0) {
                    if(printerList.getSelectionCount() > 0)
                        System.out.println(Arrays.toString(printerList.getSelection()));
                }
            });
    
            shell.pack();
            shell.open();
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                    display.sleep();
            }
        }
    }
    

    Since you already used JFace Viewers in your previous questions, I would suggest using a ListViewer here as well.

    Note:

    Since you are already familiar with TableViewer, why not use one with only one column and setHeaderVisible(false) and SWT.MULTI as style? It would basically have the same effect.

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

Sidebar

Related Questions

OK, so here is my ArrayList : private List<ClientThread> clients = new ArrayList<ClientThread>(); and
I have an array list of objects in my application. private static ArrayList<Player> userList=new
private List<String> subList; private List<List<String>> records = new ArrayList<List<String>>(); for(....){ subList = new ArrayList<String>();
I have the following in my Struts ActionForm private List<FormFile> attachmentList = new ArrayList<FormFile>();
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
private final List<KeyListener> keyListeners= new CopyOnWriteArrayList<KeyListener>(); public void addKeyListener(KeyListener keyListener){ keyListeners.add(keyListener); } In the
This is my Code : private ArrayList<Receipt> receipts = new ArrayList<Receipt>(); ArrayAdapter<Receipt> adapter; //
Here is my code: public class XMLGettersSetters { private ArrayList<String> country = new ArrayList<String>();
I would like to do something like this: private ArrayList<String[]> addresses = new ArrayList<String[3]>();
I have a array list like this: private ArrayList<Locations> Artist_Result = new ArrayList<Location>(); This

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.