NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
redpower1989
Joined: 17 Nov 2011 Posts: 2
|
Posted: Thu Nov 24, 2011 8:40 am Post subject: Import data form text into Jtable |
|
|
Hello i made a GUI. In that GUI i make a Jtable here the code that i make the Jtable with name table 1
| Code: | centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
inCenterPanel = new JPanel(new GridLayout(1, 2));
label4 = new JLabel("A= ");
inCenterPanel.add(label4);
table1 = new JTable(x, x);
table1.setBackground(Color.red);
inCenterPanel.add(table1);
centerPanel.setBackground(Color.green);
inCenterPanel.setBackground(Color.green);
centerPanel.add(inCenterPanel);
contentPane.add(centerPanel, BorderLayout.NORTH);
|
I make o method that i want the GUI read from text file and put the int elements into the jtable with name table 1! here is the code which i try to make that and i dont now how
| Code: | public void data2() {
try {
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("data.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
for (int i = 0; i < x; i++) {
for (int j = 0; j < x; j++) {
}
}
}
//Close the input stream
in.close();
} catch (Exception e) {//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
} |
Can you help me ? i make this thread also here http://www.coderanch.com/t/559727/GUI/java/Import-data-text-Jtable#2540842 |
|
| Back to top |
|
 |
jyeary
Joined: 21 Oct 2008 Posts: 610 Location: Simpsonville, SC
|
Posted: Tue Dec 06, 2011 3:33 am Post subject: Re: Import data form text into Jtable |
|
|
| This is the wrong forum for GUI based questions, please use the |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|