-2

I've lookup for some answers but none really helped me.

I have a JTable in a window which is populated with data from a DB. (This my user table)

//Creating the user table
    String[] columnNames = {"Identifiant", "Login","Prenom", "Nom", "Niveau", "Email"};
    int[] indexes = {1, 3, 4, 5, 6, 7};
    userTable = GUITools.buildTableFromDB("user", columnNames, indexes);
    scrollUserPane = new JScrollPane(userTable);

I implemented Add and Delete functions which work fine. However after deleting or adding, I would like to refresh my table to make it the exact mirror of my DB.

I tried to simply recreate it just as it is done the first time but.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
halimath
  • 15
  • 3
  • 4
    `"I've lookup for some answers but none really helped me."` -- why not tell us specifically what answers you've reviewed and why they didn't help you? This same question gets asked a lot, and so there are [many decent answers available for you to review](http://stackoverflow.com/search?q=%5Bjava%5D+jtable+%5Bjdbc%5D+abstracttablemodel). Otherwise we risk giving you the very same answers back at you that you saw before. Specifically what is it that is tripping you up or confusing you? – Hovercraft Full Of Eels Jul 20 '15 at 14:17

1 Answers1

-1

You should invoke method fireTableDataChanged inherited from AbstractTableModel to inform your JTable that your data changed.

Further information about this method can be found here: [http://docs.oracle.com/javase/7/docs/api/javax/swing/table/AbstractTableModel.html ]

user2896152
  • 762
  • 1
  • 9
  • 32