hany hashemi wrote:Hi everybody,
I have a Jtable which is filled by the data related to MySql table.I added a button and i want the JTable to add a row while i am pressing the Insert button.
This is a part of my code.
I will be appreciative if somebody can help me solving this problem.
I can't really help you solve "this problem" because you didn't actually say you had a problem. Perhaps you should describe how your code behaves differently from how you expect.
I will mention that you shouldn't have to call fireTableStructureChanged because you are using DefaultTableModel and its methods (such as addRow) fire events automatically.
Are you sure that your addNewRow method is even being called? If you put a println in there do you see any output?
I use the println and i saw that addNewRow method was called.I also comment the line related to fire a table but after pressing the insert button ,instead of adding a new row at the bottom of my table , i faced to these massages:
The complete code is not necessary. We already know from the stack trace that one field in this code is null:
Since item is a newly created Vector that can't be null, and the only other variable that is dereferenced here is model. So that tells me that model == null, probably because it was only declared and never initialized.
Karthick Dharani Vidhya
Joined: Feb 23, 2008
Hope that in the stack trace we will get "caused by".
By the line number in the trace if we can get hold of the line number that caused nullpointerexception. From the line we can see what is null.
subject: A problem adding a row in JTable using a button