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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:25:02+00:00 2026-05-13T15:25:02+00:00

I have a java SWT application that works OK with Windows XP and Windows

  • 0

I have a java SWT application that works OK with Windows XP and Windows Vista. But when I run it on Windows 7, weird errors occure, and it crashes.

For example, in a method where I call Table.removeAll() I get a java.lang.ArrayIndexOutOfBoundsException: 0. The table has SWT.VIRTUAL in style.

Another problem is when I write something in a text box (there’s a ModifyListener which filters something) – after 2 characters, the cursor moves at the beginning (before first character).

The SWT version is 3.5, but I tried with the latest from the eclipse website(3.6M3) and the result is the same.

Are there any known issues? Has anybody encountered this?


Here is a snippet that doesn’t work in Windows 7:

import java.util.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class TableCheck {

  Shell shell;

  Button button1, button2, button3;

  UltraTable ut;

  public TableCheck() {
    Display display = new Display();
    shell = new Shell(display);
    shell.setLayout(new GridLayout(4, false));
    Text text = new Text(shell, SWT.SINGLE | SWT.LEAD | SWT.READ_ONLY | SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    text.setText("SWT " + SWT.getPlatform() + " " + SWT.getVersion() + "; "
            + System.getProperty("os.name") + " " + System.getProperty("os.version") + " "
            + System.getProperty("os.arch"));

    SelectionAdapter listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (e.widget == button1) {
                ut.setContent(Arrays.asList("01", "34", "test", "test2", "123", "1test", "test2"));
            } else if (e.widget == button2) {
                ut.setContent(Arrays.asList("Str1", "Str2", "Str3"));
            } else {
                ut.setContent(Collections.emptyList());
            }
        }
    };
    button1 = new Button(shell, SWT.PUSH);
    button1.setText("Data 1");
    button1.addSelectionListener(listener);
    button2 = new Button(shell, SWT.PUSH);
    button2.setText("Data 2");
    button2.addSelectionListener(listener);
    button3 = new Button(shell, SWT.PUSH);
    button3.setText("Data 3");
    button3.addSelectionListener(listener);

    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    gd.widthHint = gd.heightHint = 320;
    ut = new UltraTable(shell, SWT.MULTI | SWT.BORDER | SWT.VIRTUAL | SWT.FULL_SELECTION);
    ut.table.setLayoutData(gd);
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
  }

  class UltraTable {
    private Table table;

    private static final String DATA_COLLECTION = "<<CC>>", DATA_LISTENER = "<<VL>>";

    public UltraTable(Composite parent, int style) {
        table = new Table(parent, style);
        table.setLinesVisible(true);
        table.setHeaderVisible(true);
        TableColumn tableColumn = new TableColumn(table, SWT.NONE);
        tableColumn.setText("Column");
        tableColumn.setWidth(64);
    }

    void setContent(Collection<?> collection) {
        if ((table.getStyle() & SWT.VIRTUAL) != 0) {
            table.setData(DATA_COLLECTION, collection);
            table.clearAll();
            table.setItemCount(collection.size());
            if (table.getData(DATA_LISTENER) == null) {
                Listener listenerSD = new Listener() {
                    public void handleEvent(Event event) {
                        Collection<?> collectionW = (Collection<?>) event.widget.getData(DATA_COLLECTION);
                        Object object = collectionW.toArray(new Object[collectionW.size()])[event.index];
                        ((TableItem) event.item).setText(0, object.toString());
                    }
                };
                table.setData(DATA_LISTENER, listenerSD);
                table.addListener(SWT.SetData, listenerSD);
            }
        }
    }
  }
  public static void main(String[] args) {
    new TableCheck();
  }
}

The SWT versions I checked is (as shown in the text in the shell):

SWT win32 3550; Windows 7 6.1 x86
SWT win32 3617; Windows 7 6.1 x86

  • 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-13T15:25:03+00:00Added an answer on May 13, 2026 at 3:25 pm

    On Windows 7, the table updates the visible items immediately when clearAll() is called. So
    table.clearAll();
    must be after the line
    table.setItemCount(collection.size());

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

Sidebar

Ask A Question

Stats

  • Questions 293k
  • Answers 293k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've been searching for a solution for this problem myself,… May 13, 2026 at 6:22 pm
  • Editorial Team
    Editorial Team added an answer Hash tables are very commonly used for this. A simple… May 13, 2026 at 6:22 pm
  • Editorial Team
    Editorial Team added an answer In Objective-C, sending a message to nil (a null reference… May 13, 2026 at 6:22 pm

Related Questions

Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
We're running Java Swing and are using an SWT bridge to get ahold of
When I launch an SWT application (via an Eclipse launch profile), I receive the
I have an RCP product which doesn't run. Then I installed Eclipse freshly, and
I am trying to communicate with Excel from a Java/SWT application. I have been

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.