tablemodel

Java, change a cell content as a function of another cell in the same row

穿精又带淫゛_ 提交于 2019-11-26 07:47:58
问题 I need some help for my problem. I have a table with e.g. a double column and a string column. If the value in the double column is negativ, the string should be \"negativ\". And the other way if the value is positiv, the string should be \"positiv\". The problem is now if I edit the double value in the jTable, the string should also be updated. Update to my question, the actual code look like this: But it doesn\'t work, because the string in the second column wont be updated after I edit the

JTable How to refresh table model after insert delete or update the data.

白昼怎懂夜的黑 提交于 2019-11-26 03:24:26
问题 This is my jTable private JTable getJTable() { String[] colName = { \"Name\", \"Email\", \"Contact No. 1\", \"Contact No. 2\", \"Group\", \"\" }; if (jTable == null) { jTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { return false; } }; } DefaultTableModel contactTableModel = (DefaultTableModel) jTable .getModel(); contactTableModel.setColumnIdentifiers(colName); jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); return jTable; } I will call this method to

JTable How to refresh table model after insert delete or update the data.

大兔子大兔子 提交于 2019-11-25 21:00:53
This is my jTable private JTable getJTable() { String[] colName = { "Name", "Email", "Contact No. 1", "Contact No. 2", "Group", "" }; if (jTable == null) { jTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { return false; } }; } DefaultTableModel contactTableModel = (DefaultTableModel) jTable .getModel(); contactTableModel.setColumnIdentifiers(colName); jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); return jTable; } I will call this method to retrieve the data from database and put it into table model public void setUpTableData() { DefaultTableModel