File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Displaying information from a text file in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Displaying information from a text file in a JTable" Watch "Displaying information from a text file in a JTable" New topic
Author

Displaying information from a text file in a JTable

dave green
Greenhorn

Joined: Oct 15, 2007
Posts: 10
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

Joined: Oct 29, 2001
Posts: 8710
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
dave green
Greenhorn

Joined: Oct 15, 2007
Posts: 10
Thanks alot for that, I was obviously trying to overcomplicate it. Have found a much easier way
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying information from a text file in a JTable
 
Similar Threads
jtable
Customizing JTable
JTable(!!!)
How to Display a JTable with the Data
JTable cell rendering