Reputation: 47
I am facing the problem of passing value to print it out in the jtable. I am trying to pass my data variable to the table but I am getting error once I trying to run the project. The image below shown what i tried.
I declare these 2 variable in global.
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
String[] headers = {"IP", "Port", "Destination", "Port"};
I pass in the value what i read from the text file into data variable as this:
Vector<Object> row = new Vector<Object>();
row.add(allTCP.get(x).getTCPSourceIP());
row.add(allTCP.get(x).getTCPSourcePort());
row.add(allTCP.get(x).getTCPDestIP());
row.add(allTCP.get(x).getTCPDestPort());
data.add(row);
Can anyone tell me what i did wrong or what shall i do in order for me pass in the value to output as table form. By the way, I designed my table in third tab.
Upvotes: 0
Views: 769
Reputation: 324128
Read the DefaultTableModel
API.
You can create a DefaultTableModel
using:
You can't create the model using an array and a Vector.
Upvotes: 3