Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable not showing data

 
Krit Christoforou
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I'm trying to create a Jtable and make it load the contents of a vector after i press a button.
The problem is that the table wont display what it should, instead it remains empty.
I know that my vector is loaded because i print out its contents in the command line.

Here is some code, i hope that helps.
Thanks

 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the JavaDocs for the JTable(Vector rowData, Vector columnNames) constructor:
Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.
Does your data Vector (newVect) hold Vectors of Strings, or just Strings directly?
 
Krit Christoforou
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again david
always helpful hehe

The vector holds vectors of strings.
i changed some things in the code and got it to work. I cant get it to work with a scrollpane tho.
Here is my code:




The strange thing is that if i uncomment the scrollpane lines, the table remains empty, i cant get it to load the vector.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic