Results 1 to 2 of 2
- 02-22-2011, 05:58 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
Creating Jtable and reading a txt file of numerical data
Hello,
I am very new to java and netbeans.
I have problem with in making jtable read a txt file with numerical data.
The txt file contains the data in following format.
-------------------------------
title1 title2 title3 title4 title5
123 123 123 123 123
. . . . .
. . . . .
-------------------------------
I created jtable but dont know how to write code for making this data read by the jtable. the data is very huge...
This Assignment is to be made in NETBEANS RCP.
After making the data read by the jtable I have to use jfree chart to create graph for 1st column vs 2nd column, 1st column vs 3rd column and so on..
Please any one kindly help me...
-
One possible solution is to read the title data into a vector of objects, Vector<Object>, and then read each row of numeric data into another Vector<Object>. Each row of data should then be placed in a vector of vectors, Vector<Vector<Object>>. Then have a look at the DefaultTableModel API and you'll see constructor that uses two Vectors as parameters. Create a new DefaultTableModel with the two Vector's you've created above, and then insert this model into your JTable using the table's setModel method.
I would first try to do this with hard-coded data and not worry about reading in from a file in the beginning. Create a small application that just creates the DefaultTableModel, places it in a JTable, and displays the JTable, perhaps as simply as putting it in a JOptionPane. Then if you get stuck trying this, show us your small code and any errors, and we can better be able to help you.
Much luck!
Similar Threads
-
Reading from file and adding to JTable
By purple in forum New To JavaReplies: 11Last Post: 04-14-2011, 10:33 PM -
Reading Numerical Data
By tyang in forum New To JavaReplies: 1Last Post: 02-05-2010, 03:19 AM -
java project help, reading in from a file and adding data to JTable
By Ekul in forum New To JavaReplies: 0Last Post: 11-24-2009, 01:49 PM -
Reading data to file
By puk284 in forum Advanced JavaReplies: 1Last Post: 04-28-2009, 03:19 PM -
Reading and writing the contents of jtable into a text file
By Manfizy in forum NetBeansReplies: 6Last Post: 12-12-2008, 03:35 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks