Java/Swing dialog box appears on the user's screen
It allows the user to enter 2 values into labelled text fields (fname/sname)
They select a "Click Me" push button which I hope will write the data into the table
But the table does not get refreshed.
If I minimise the dialog box and then open it again, the data still does not appear.
The code I originally built using eclipse/WindowBuilder.
I've cut it back and tried to isolate the issue.
But I still cannot figure it out.
I've added some diagnostic log messages to ensure that I am seeing the various events I think I need to see and have put code in the action callbacks etc.
As I am a complete newbie at this sort of thing I am probably doing something silly - or forgetting to do something - or completely missing some significant point.
Can someone help me out with this please?
And thank you in advance.
You are using the wrong DefaultTableModel constructor. You should create the model by only using the column names and 0 rows of data, since your data will be entered by the user and you don't know how many rows will be added. Read the DefaultTableModel API for the appropriate constructor to use
To update data in the table, you need to update the data in the TableModel. You do this by using the addRow(...) method of the DefaultTableModel:
The TableModel will then notify the table that the data has changed and the table will repaint itself automatically.
Joined: Jun 05, 2014
That's it Rob!
Got it straight away.
Its that old TableModel stuff that I need to get my head around and the relationship between Tables and TableModels.
Thank you for your help....now on to my next conundrum.