File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Populating JTable from a textfile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Populating JTable from a textfile" Watch "Populating JTable from a textfile" New topic
Author

Populating JTable from a textfile

neo
Greenhorn

Joined: Feb 05, 2007
Posts: 2
Hi All,
I have some questions. Which are,
1. I am going to read from a text file, one line at time,(may be may not be) and store the content in a Vector. Then a part of the line(not the whole line)
1.1 Separated by a specified delimeter
1.2 Not Seperated by a specified delimeter
will be shown in each JTable cell.
I have tried this,but the whole line is coming in a single cell. How to avoid this ?
And how to fetch the data for each cell, from the text line when there is no specified delimeter(In this case, "space/Tab" is the delimeter). In JTable I have used DefaultTableModel(each row is vector of Vectors)

2.Is it fine to use DefaultTableModel as my JTable model, for the type of operation that I am going to perform ? If yes, how if no Why ?

Hope to get help from you.
Please explain with example code

Thanking you
neo
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Please explain with example code

first explain the problem with actual code

it takes a lot less time to add a line (or fix a line) to posted code
than it does to build a gui to 'requirements'
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

"neojava java", welcome to JavaRanch.

We're friendly people here, but we do require members to have valid display names.

Display names must contain your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names will be deleted.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

"neo"

Your name still does not conform to our naming policy. Please correct it right away. This is your second warning.


My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating JTable from a textfile