Hey Guys,

i was looking at the post linked below and been trying to solve the issue, however, i have been unable to solve it.

Click Here

The post says i "MUST create a new Vector for each row" in order for it to work. as mentioned above, i have tried doing this but failed.

Would really appreciate some help.

The code i have is displayed below:

package game;

import java.awt.BorderLayout;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class HighScores {
  public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Vector<String> v = new Vector<String>();
    Vector<Vector<String>> myVector = new Vector<Vector<String>>();
    try{
           FileReader fReader = new FileReader("playerscores.txt");
           BufferedReader inFile = new BufferedReader(fReader);
           String input;
       String[] temp;
        while((input=inFile.readLine())!=null)
        {
                    temp = input.split(",",6);
            for(int i=0;i<temp.length;i++){
                v.add(temp[i]);
                System.out.println(temp[i]+" added");
            }
            System.out.println("V is "+v);
            myVector.add(v);
            System.out.println("---------End of Line");
                Vector<String> columnNames = new Vector<String>();
                columnNames.addElement("Player Name:");
                    columnNames.addElement("Score:");
                JTable table = new JTable(myVector,columnNames);
            JScrollPane scrollPane = new JScrollPane(table);
            frame.add(scrollPane, BorderLayout.CENTER);
            frame.setSize(600, 150);
            frame.setVisible(true);
        }
    }catch(Exception e){
        System.out.println("ERROR");
    }
  }
}

Hey M/, Yh i did it is already implemented within the code.

okay, when i get home (i am right now out of the city, will be back in a few hours) i will try my best to fix up your code for you (i am sorry if i forget).

In the mean time, someone else might be able to help you, so expect someone like James, Tins, ddanbe, etc. to help out.

I sorted this issue, but thank you for your help!

oh, how did you solve. do you mind posting your code so others can learn from your mistakes. (i am 10 minutes away from doing my event (100 meter) :D).

Also mark the question solved if you are satisfied and congrats on, technically, self solving your question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.