Hi,
I'm working on a simple program to take orders for a company, and I'm using a JTable to display a list of products, very simple - only a few columns and all non-editable text at the moment.
I am adding items to a JTable during runtime and I've run into something weird that has been puzzling me for a good few hours.
Here is the (important part of) my Table Model:
public class OrderTableModel extends AbstractTableModel {
// blah...
public void addOrder(PipeOrder order){
// add order to the array of order items
fireTableDataChanged();
orders[orderCount].getPipe().print();
}
What happens though, is when the item is added, all the other items in the table are set to the same attributes as the one i've just added!
E.g.
Before:
col 1 | col 2 | col 3 |
A A A
Adding {B, B, B}...
After:
col 1 | col 2 | col 3 |
B B B
B B B
This is driving me up the wall, does anyone have any idea what might be wrong?
I've tested my getValueAt()
method by setting the value returned to the row and column index (e.g. x,y), and I know the method is being called with the right coordiantes. Also, at the print method in the code above, the right data is output to the console, it just isn't being displayed properly in the table.
Any suggestions or tips would be really helpful!
Thanks :)
PS: first time poster, so Hi everyone!