We help IT Professionals succeed at work.

JTable in java

deko007
deko007 asked
on
Hi evry one

I am building a client server program,in the client side it will be a table that can be changed according to the database in the server(MYSQL) and the user can change data on the table that will update the data base oon the server.
In my program the table is changing if deleting a row in the database  table,and if then adding a row,but if i adding a row that exceed the original number of lines the data base chnage but the table is not.
Any ideas?
Comment
Watch Question

Awarded 2011
Awarded 2011

Commented:
That may depend on implementation of your datamodel
Do you have some simpilfied code to post?

Author

Commented:
This is the table model:

TableModel dataModel=new AbstractTableModel()
  {

     public int getColumnCount(){ try{return rsmd.getColumnCount();}catch(Exception e){}return 0;}

    public int getRowCount(){return dataVec.size();}

    public Object getValueAt(int row,int col){return ((Vector) dataVec.elementAt(row)).elementAt(col);}

    public String getColumnName(int column){return colNames[column];}
 };

whene receiving an update from the server i delet the old vec and add new data to it
Awarded 2011
Awarded 2011

Commented:
But I guess you still sometimes need to repaint() the table to run through all these methods.

It still does not change?

Are you showing it in JScrollPane() window ?

Author

Commented:
the table is on jscrollpane just the repaint isnt working
Awarded 2011
Awarded 2011

Commented:
maybe you want to do that after changing  vector:
tableModel.fireTableDataChanged()

see:
http://stackoverflow.com/questions/3179136/jtable-how-to-refresh-table-model-after-insert-delete-or-update-the-data

Author

Commented:
i am know trying another way when this will be good i'll be in touch.
DO you know when can i finde a fuul program solution for JTable instead of  build that my self?
Awarded 2011
Awarded 2011
Commented:

Author

Commented:
Thanks i will use this guids and make my own classes