hi everybody ,
I really appreciate if you could help me in displaying the datas of .txt file in JTable .....my codes are below ..really new to JAVA so pleaese help
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTable;
import java.io.*;
public class DisData{
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BufferedReader r=new BufferedReader(new FileReader("Data.txt"));
String line =r.readLine();
while (line!=null){
Object rowData[]=line.split(","); // having error at this point
}
Object columnNames[] = { "Name", "Address", "Mobile" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
I really appreciate if you could help me in displaying the datas of .txt file in JTable .....my codes are below ..really new to JAVA so pleaese help
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTable;
import java.io.*;
public class DisData{
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BufferedReader r=new BufferedReader(new FileReader("Data.txt"));
String line =r.readLine();
while (line!=null){
Object rowData[]=line.split(","); // having error at this point
}
Object columnNames[] = { "Name", "Address", "Mobile" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}