• Post Reply Bookmark Topic Watch Topic
  • New Topic

DefaultTableModel's add row method inserting empty line vectors.  RSS feed

 
Josh Borg
Ranch Hand
Posts: 37
Chrome Eclipse IDE Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to add rows with List of String converted in Object arrays by Array.asList method, and it is inserting Vectors with nothing inside. I tried addColumn and it works perfectly, but in this case Lists represents rows.

(There is values in these Lists).



Thanks.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post your SSCCE that demonstrates the problem.
 
Josh Borg
Ranch Hand
Posts: 37
Chrome Eclipse IDE Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:Post your SSCCE that demonstrates the problem.


I am using defaultTable's addRow to insert an object array in a table, but everything seems there is an empty Vector.





 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is NOT a SSCCE. How to we compile/execute the code?

Again, we don't want your entire application. We just want you to create a simple demo that uses the addRow(...) method to prove to yourself that it works or doesn't work. If it works, then great your comare the working SSCCE to your real code to see what the difference is. If it doesn't work, then you have simple code to post.
 
Josh Borg
Ranch Hand
Posts: 37
Chrome Eclipse IDE Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, thanks for the explanation, it still does not work.

 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DefaultTableModel needs to know the number of columns. Usually you would create the DefaultTableModel with a Vector/Array of the columns names.

Or for a quick test you can use the default columns names by just using:

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!