• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying information from a text file in a JTable

 
dave green
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help,

I am trying to create a reports program for a test program I created. The results are saved in a .txt file with a "/" seperator and each new test is saved to a new line in the file. I then want to be able to view the results in a JTable. I can get it to work for only the first result. How do I get it to create a new row for each line of the text document?

I am using String [][] data = new String [][]{{results[0], results[1]}} when reading from the file. I am probably going about this the wrong way, I know I would need to use an int variable for results[0] etc which i could do i am just not sure how to make it create a new row so that i would need to do it.

Any help appreciated
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.
Have you looked at the API Documentation for JTable? Perhaps there is an easier way to collect data from your file and pass it in to the JTable constuctor.
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
dave green
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot for that, I was obviously trying to overcomplicate it. Have found a much easier way
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic