Pergunta

Hej. There is a collection with data.

static ArrayList<MyBeans> all = new ArrayList<MyBeans>();

There is a jTableModel too which invoke this table on jFrame.

TableModel model = new Table(all);
JTable table = new JTable(model);

For example, at some moment ArrayList<MyBeans> all was changed. What should do for change this table too?

Foi útil?

Solução

If your all ArrayList<MyBeans> (which by the way should not be static) is the nucleus of a TableModel, then your problem is that you're trying to make changes directly to the ArrayList which you should never do. Instead you should make changes only by calling public methods in your TableModel, and these methods should fire the appropriate AbstractTableModel notification method that will notify any registered listeners (here, the displayed JTable itself) of any changes to its model.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top