hi!

I have 2 columns SWT table.
but when I insert data (from Mysql query), it appear only in the first column.
for make it show in the second, I have to change the size of the column and then the data appear.

so right now, after every query, I change the column width automatically, and it works.

anyway, I wanna know why does it happen? and get the real solution for that problem.

-Nate

It happens because changing the size of the column indirectly causes the layout() method to be called on your widget. In order to dynamically insert data into the table, you could just call layout() on the table after you add the data. Then you won't need to reset the column size.

Thanks!

could you show me exactly what I should write?

will it make all the column appear?

right now, every time i change the column width, only the rows which I can see, are updated (the table could be scrolled).

thanks again!
-Nate

It happens because changing the size of the column indirectly causes the layout() method to be called on your widget. In order to dynamically insert data into the table, you could just call layout() on the table after you add the data. Then you won't need to reset the column size.

It's doesn't work for me...

could u think about something else?

Thanks,
Nate

Can you show me what you tried doing? Just the relevant parts, like setting the table data then attempting to redisplay it. You might also try calling the layout() method on the Display that contains the table. Basically calling it on the outer component might work. I forget the correct terminology and TBH I don't have Eclipse installed right now due to a hard drive failure and subsequent wipe, so I'm not in a position to test anything.

Can you show me what you tried doing? Just the relevant parts, like setting the table data then attempting to redisplay it. You might also try calling the layout() method on the Display that contains the table. Basically calling it on the outer component might work. I forget the correct terminology and TBH I don't have Eclipse installed right now due to a hard drive failure and subsequent wipe, so I'm not in a position to test anything.

the window which contain the table is a composite.
in my project, there are some composites in tabs.

here is the code which update the table:

public LinkedList<String> results;

	private void displayResults() {
		if (results == null || results.size() < 1) { // if there wasn't found any results.
			// OPTION - prompt a message box - "NO RESULTS".
			return;
		}
		String sep = FileSystems.getDefault().getSeparator(); // get the system path seperator.
		String s;
		int i;
		Iterator<String> it = results.iterator();
		while (it.hasNext()) {
			// decompose the string to file address and name:
			s = it.next();
			i = s.lastIndexOf(sep);
			TableItem item = new TableItem (resultsTable, SWT.NONE);
			if (i > 0) { // if there is seperator and not as first char:
				item.setText (new String [] {s.substring(i+1), s.substring(0, i)});
			} else {
				item.setText (new String [] {s, ""});
			}
		}
		
	}

I have 5 columns SWT table.
but when I insert data (from using addSelectionListener), it appear only in the first column.What i do?
i add data on add button click,but it appear only in 1st column.
plz help me!

what to do? first you realize that this thread is two years old, and nobody is still following it. secondly, create a new thread in which you ask your question.

there are thousands of things that can go wrong, but what it is is pretty hard to know if we don't see any of the code, so.
1. create a new thread
2. explain the problem clearly
3. post any relevant code
4. post any exception or error messages you get.
5. is there an exception or error, or is the result just not what you expect it to be?

This article has been dead for over six months. Start a new discussion instead.