Note that there are some explanatory texts on larger screens.

plurals
  1. POJava. JTable setValueAt data not update
    text
    copied!<p>I try to use JTable but when I invoke setValueAt method data don't update in gui. I try to find the answer more then 5 hours but anything help me.</p> <p>I try to updateUI and fireTableDataChanged() but id doesn't help.</p> <p>I use AbstractTableModel and my constructor is JTable(MemoryTableModel). Look at my code of MemoryTableModel:</p> <p>What i`m doing wrong, or what I forget?</p> <p>(Sorry for my english, its not my native language)</p> <pre><code>public class MemoryTableModel extends AbstractTableModel { private static final long serialVersionUID = 1L; ArrayList&lt;ArrayList&lt;Object&gt;&gt; memoryCells; String[] columnNames = {"Offset", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}; public MemoryTableModel(byte[] data, int cells) { super(); memoryCells = new ArrayList&lt;ArrayList&lt;Object&gt;&gt;(); for (int i=0; i&lt; cells/16; i++) { ArrayList&lt;Object&gt; a = new ArrayList&lt;Object&gt;(); a.add(i); for (int j=0; j&lt;16; j++) { a.add(data[i*16+j]); } memoryCells.add(a); } } @Override public int getColumnCount() { return columnNames.length; } @Override public int getRowCount() { return memoryCells.size(); } public String getColumnName(int col){ return columnNames[col]; } @Override public Object getValueAt(int line, int column) { return memoryCells.get(line).get(column); } @Override public void setValueAt(Object cell, int row, int column) { memoryCells.get(row).set(column, cell); fireTableDataChanged(); } public boolean isCellEditable(int rowIndex, int columnIndex) { if (columnIndex == 0) return false; return true ; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload