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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:24:48+00:00 2026-06-11T19:24:48+00:00

I am trying to write a method that will get the current selections from

  • 0

I am trying to write a method that will get the current selections from the table and create a ArrayList from the selections.

Method:

 public void getPlotterSelection() {
   selPrinters = new ArrayList<PrinterProfile>();
   int[] row = table.getSelectionIndices();
   Arrays.sort(row);
   if (row.length > 0) {
     for(int i = row.length-1; i >= 0; i--){
        PrinterProfile pp = new PrinterProfile(aa.get(i).getPrinterName(), aa.get(i).getProfileName());
        selPrinters.add(pp);
     }
  }
}

This is the error I am getting

ERROR: 16:16:49,503 – TcLogger$IC_LogListener.logging:?
org.eclipse.core.runtime – org.eclipse.ui – 0 – Unhandled event loop exception
org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(SWT.java:3884)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770)
at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:336)
at org.eclipse.swt.widgets.Table.getSelectionIndices(Table.java:2536)
etc …….

The problem is with this line of code

int[] row = table.getSelectionIndices();

Once again..

I am trying to get the user selected rows in the table and put them in a arraylist.

Edit Adding more code

 //////////////////////////////////////////////////////////////////////////
 //                       createDialogArea()                             //
 //////////////////////////////////////////////////////////////////////////
 protected Control createDialogArea(Composite parent) {
  final Composite area = new Composite(parent, SWT.NONE);
  final GridLayout gridLayout = new GridLayout();
  gridLayout.marginWidth = 15;
  gridLayout.marginHeight = 10;
  area.setLayout(gridLayout);

  GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
  area.setLayoutData(gridData);
  checkingArray();
  createCopyNumber(area);
  createPlotterTable(area);
  return area;
}

public void checkingArray() {
   aa = abd.getPrintersArray();
}

//////////////////////////////////////////////////////////////////////////
//                     createPlotterTable()                             //
//////////////////////////////////////////////////////////////////////////
private void createPlotterTable(Composite parent) {
  Composite composite = new Composite(parent, SWT.BORDER); 
  GridLayout gridLayout = new GridLayout(1, false);
  composite.setLayout(gridLayout);
  GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
  composite.setLayoutData(gridData);

  //gridData = new GridData(SWT.FILL, SWT.FILL, true, true ); 
  table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
  table.setHeaderVisible(true);
  table.setLinesVisible(true);

  TableColumn[] column = new TableColumn[2];
  column[0] = new TableColumn(table, SWT.FILL);
  column[0].setText("Printer Name");
  column[0].setWidth(200);

  column[1] = new TableColumn(table, SWT.FILL);
  column[1].setText("Profile Name");
  column[1].setWidth(200);

  gridData = new GridData();
  gridData.verticalAlignment = GridData.FILL;
  gridData.horizontalAlignment = GridData.FILL;
  gridData.grabExcessHorizontalSpace = true;
  gridData.grabExcessVerticalSpace = true;
  table.setLayoutData(gridData);

  fillTable(table);
  table.setRedraw(true);
} 

private void fillTable(Table table) {
  table.setRedraw(false);

  for(Iterator iterator = abd.getPrintersArray().iterator();iterator.hasNext();){
     PrinterProfile printer = (PrinterProfile) iterator.next();
     TableItem item = new TableItem(table, SWT.FILL);
     int c = 0;
     item.setText(c++, printer.getPrinterName());
     item.setText(c++, printer.getProfileName());
  }
table.setRedraw(true);
} 

 public void getPlotterSelection() {

   selPrinters = new ArrayList<PrinterProfile>();

   int[] row = table.getSelectionIndices();

   Arrays.sort(row);
   if (row.length > 0) {
     for(int i = row.length-1; i >= 0; i--){
        PrinterProfile pp = new PrinterProfile(aa.get(i).getPrinterName(), aa.get(i).getProfileName());
        selPrinters.add(pp);
     }
   }
}  

This is the button that calls the method

 Button okButton = createButton(parent, IDialogConstants.OK_ID, "OK", true);
   okButton.setEnabled(true);
   okButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
         getPlotterSelection();
      }
   });
  • 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-11T19:24:49+00:00Added an answer on June 11, 2026 at 7:24 pm

    I would suggest you to user Table viewer rather than Table. It makes your life easier. I see that you are showing table in a dialog. I guess your dialog is getting closed/disposed when you click OK before it get to getPlotterSelection() method.

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

Sidebar

Related Questions

I'm trying to write a method that will get a private field in a
I'm trying to write a method that will compute all permutations of a power
I am trying to write an Audit Log method that will log all changes
What I'm trying to do is write a method that will return all of
I'm trying to write an extension method for objects that will dump the structure
All, I am trying to write a cross platform (hence: boost) method/function that will
I'm trying to write a method that removes all non alphabetic characters from a
I am trying to write a generic method that will convert a DataTable to
I am trying to write a Python script that will copy files from one
I'm trying to write a method that will determine which computers in my domain

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.