Results 1 to 2 of 2
- 02-22-2011, 06:58 AM #1Member
- Join Date
- Feb 2011
- Rep Power
Creating Jtable and reading a txt file of numerical data
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.
- By purple in forum New To JavaReplies: 11Last Post: 04-14-2011, 10:33 PM
- By tyang in forum New To JavaReplies: 1Last Post: 02-05-2010, 04:19 AM
- By Ekul in forum New To JavaReplies: 0Last Post: 11-24-2009, 02:49 PM
- By puk284 in forum Advanced JavaReplies: 1Last Post: 04-28-2009, 03:19 PM
- By Manfizy in forum NetBeansReplies: 6Last Post: 12-12-2008, 04:35 PM