Help with JTable ResultSet
I have this code in a few of my java classes. I love this table, because I can sort by the columns easily. Here is part of the class.
public StatusChassisPanel()
{
setBorder(BorderFactory.createTitledBorder("Status - Chassis Panel"));
Object rows[][] ={
{"image",0,"1756-L63/A L6x_15_24", 15.3,"0x001BE2DB"},
{"image",1,"1756-CNB/B", 2.30,"0x00055A6B"},
{"image",2,"1756-ENET/B ", 2.7,"0x00041474"},
{"image0",3,"Empty", 0.0,""},
{"image0",4,"Empty", 0.0,""},
{"image",5,"1756-L1/A LOGIX5550", 13.31,"0x0005EA7B"},
{"image",6,"1756-DH485/A (Q1)", 1.2,"0xD00337E8"},
{"image0",7,"Empty", 0.0,""},
{"image0",8,"Empty", 0.0,""},
{"image",9,"1756-OB16I/A DCOUT ISOL", 2.1,"0xC00260A6"}
};
String columns[] ={" ","Slot","Module","Revision","Serial Number"};
TableModel model =
new DefaultTableModel(rows, columns){
public Class getColumnClass(int column){
Class returnValue;
if ((column >= 0) && (column < getColumnCount())){
returnValue = getValueAt(0, column).getClass();
}else{
returnValue = Object.class;
}
return returnValue;
}
};
JTable table =new JTable(model);
RowSorter<TableModel> sorter =
new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane =new JScrollPane(table);
add(pane, BorderLayout.CENTER);
}
}
As you can see the Object rows[][] is already defined. I would like to parse an XML file, and send the data to this Object rows[][]. How can I do this? To see how I am parsing the xml file you can go to this thread.
http://forum.java.sun.com/thread.jspa?threadID=5120315&tstart=0
Also. where the object row is an image. I would like to place an image there from a file, depending on the row parameters. Any suggestions.
orozcom

