Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable not showing  RSS feed

 
Csaba Kassitzky
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. I'm trying to make a net watcher program, which detects changes in sites and shows them. I'm using vectors to store the content of the files and JTable to show the differences. However, it never refreshes(always shows old(unmodified) data). I know the vectors are changing, so the problem is after that point. I'm using Model-view-Control model, here's what happens:
1. Model calculates what to do with the lines and creates the right size of View:

2. Model sends the data to the control like this:

3. Control sends it forth to the appropriate View:

And finally View puts it in the right place:

Showing goes like this:


Does anyone know why it never shows the new stuff?
The vectors are cleared after a cycle, and their content changes. Init runs every time and the cells are set to a value. What is wrong with this?
 
Brian Cole
Author
Ranch Hand
Posts: 932
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you call myTable.setValueAt() the table
cell should be updating visually. Can you confirm
that myTable.setValueAt() is actually getting
called, perhaps by calling System.out.println("foo")
immediately after calling myTable.setValueAt().

Also, when you say "Model calculates" and "Model
sends" what exactly do you mean. Do you have some
kind of model object that is not a TableModel? If
so it might be a whole lot easier to just have it
implement javax.swing.table.TableModel. (Better yet,
have it extend javax.swing.table.AbstractTableModel.)
I'm not sure what you gain by having some sort of
"model" object distinct from the table model, though
of course I don't know exactly what your goals are.
 
Csaba Kassitzky
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Model is the engine of my program. It doesn't have anything to do with TableModel. Every time i try to draw, the following is surely called:

Then accoring to the files several times:

And finally

Even if i close the window, after some time(10sec is the sleeping time) the window reappears, but it shows the same content, not the newest.
 
Csaba Kassitzky
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, problem solved. It happened, because i didn't remove the scrollPane before adding the new one. One other problem appeared:
If i start 3 threads at start, only 1 shows me the View. It caused me a lot of headaches, since i tried to automatize cleaning, and i got Nullpointerexception because i tried to remove the "not-yet-existing" scrollpanes. I fixed the problem with a watcher, who detects if the window was created, but still i would like to know why only 1 of the 3 threads starts running properly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!