Hello. The bottom line is this.
There is a database that contains several columns. There is a jFrame in which the output of the database in the table to the screen is implemented via jTableModel. The mediator between the database and jTableModel is a collection that is filled with values ββwhen connected to the database. Also in jFrame there is a form for adding new values ββto the database (several text fields for filling + button to write), which works. The program is implemented in such a way that when a new value is added via the form, it is immediately stored in the database via an SQL query, and then immediately added to the collection. I want these changes to also pass dynamically with a table in jFrame. In this case, I probably should use TableModelListener. But in what case will it work? Maybe I should still + to all of this as a kind of re-supply a new collection to the table, as here TableModel model = new Table(all) ???
static ArrayList<MyBeans> all = new ArrayList<MyBeans>();// ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ TableModel model = new Table(all); JTable table = new JTable(model);//ΡΠ°Π±Π»ΠΈΡΠ° //ΠΠΈΠ½Π°ΠΌΠΈΡΠΈΡΠΊΠΎΠ΅ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ table.getModel().addTableModelListener(new TableModelListener(){ @Override public void tableChanged(TableModelEvent e) { System.out.println("zzz");//ΠΠ°ΠΊΠΎΠ΅ Π½ΠΈΠ±ΡΠ΄Ρ ΡΠΎΠ±ΡΡΠΈΠ΅ Π½Π° Π·Π°ΠΏΡΡΠΊΠ° ΠΎΠ±ΡΠ°Π±ΠΎΡΡΠΈΠΊΠ° } }); I am sure that presenting it without a code is not easy, but the code is cumbersome, I think there is no need to insert it. If required, I can make additional explanations. Thanks in advance.