i am using jdom to read contents from xml file.i am trying to put the field read in a table created in java.the problem is that when i am getting the contents and printing it in the console every thing is going well.but when i add the contents to a jtable the first item read is simply repeated in all the cells of the table.
my code is:
public class Provider{
void run()
{
try{
String s,s1;
JPanel p=new JPanel();
Vector<Vector> data=new Vector<Vector>();
Vector<List> row = new Vector<List>();
Vector columns;
columns = new Vector();
columns.addElement("item");
columns.addElement("quantity");
message1="";
message2="";
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File("dec12.xml");
Document document = (Document) builder.build(xmlFile);
Element rootNode = document.getRootElement();
List list = rootNode.getChildren("DSPVCHSTOCKITEM");
List list1 = rootNode.getChildren("DSPVCHBILLEDQTY");
for (int i=0; i< list.size(); i++)
{Element e=(Element)list.get(i);
Element e1=(Element)list1.get(i);
System.out.println(e.getContent());
System.out.println(e1.getContent());
row.addElement(e.getContent());
row.addElement(e1.getContent());
data.addElement(row);
}
final JTable table = new JTable(data, columns);
table.setRowSelectionAllowed( true );
table.setColumnSelectionAllowed( true );
JScrollPane scrollPane = new JScrollPane(table);
p.add( scrollPane ,BorderLayout.CENTER);
JFrame f=new JFrame();
f.add(p);
f.setSize(600,400);
f.setVisible(true);
}
catch(JDOMException jdomex)
{
System.out.println(jdomex.getMessage());
}
public static void main(String args[])
{
Provider server = new Provider();
while(true)
{
server.run();
}
}
}
apreciate any help
thanx