I made reference to a number of methods.
That the effective way for fireTableCellUpdated.
But in fact I still do not apply.
How to make the table content update in the after DETA value update.
The method I call GJJ method implementation.
Although updated but the emergence of many new window.
This is not my needs.
Tell me how to add a button in the new window and listening button to perform the update behavior
friend told me how to do it.
class MyTable extends AbstractTableModel {
Object p[][]={
{DETA_1_1,DETA_1_2, DETA_1_3, DETA_1_4, DETA_1_5},
{DETA_2_1,DETA_2_2, DETA_2_3, DETA_2_4, DETA_2_5},
{DETA_3_1,DETA_3_2, DETA_3_3, DETA_3_4, DETA_3_5},
{DETA_4_1,DETA_4_2, DETA_4_3, DETA_4_4, DETA_4_5},
{DETA_5_1,DETA_5_2, DETA_5_3, DETA_5_4, DETA_5_5},
{DETA_6_1,DETA_6_2, DETA_6_3, DETA_6_4, DETA_6_5},
{DETA_7_1,DETA_7_2, DETA_7_3, DETA_7_4, DETA_7_5},
{DETA_8_1,DETA_8_2, DETA_8_3, DETA_8_4, DETA_8_5},
{DETA_9_1,DETA_9_2,DETA_9_3,DETA_9_4,DETA_9_5},
{DETA_10_1,DETA_10_2,DETA_10_3,DETA_10_4,DETA_10_5},
{DETA_11_1,DETA_11_2,DETA_11_3,DETA_11_4,DETA_11_5},
{DETA_12_1,DETA_12_2,DETA_12_3,DETA_12_4,DETA_12_5},
{DETA_1_3_1,DETA_1_3_2,DETA_1_3_3,DETA_1_3_4,DETA_1_3_5},
{DETA_1_4_1,DETA_1_4_2, DETA_1_4_3, DETA_1_4_4, DETA_1_4_5},
{DETA_15_1,DETA_15_2,DETA_15_3,DETA_15_4,DETA_15_5},
{DETA_16_1,DETA_16_2,DETA_16_3,DETA_16_4,DETA_16_5},
{DETA_17_1,DETA_17_2,DETA_17_3,DETA_17_4,DETA_17_5},
{DETA_1_8_1,DETA_1_8_2,DETA_1_8_3,DETA_1_8_4,DETA_1_8_5},
{DETA_19_1,DETA_19_2,DETA_19_3,DETA_19_4,DETA_19_5}
};
String[] n = { "NO","CARD","NAME","NAME2","time" };
public int getColumnCount() {
return n.length;
}
public int getRowCount() {
return p.length;
}
public String getColumnName(int col) {
return n[col];
}
public Object getValueAt(int row, int col) {
return p[row][col];
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
}
private void GJJ() {
JFrame f = new JFrame();
MyTable mt = new MyTable();
JTable t = new JTable(mt);
t.setPreferredScrollableViewportSize(new Dimension(550, 30));
JScrollPane s = new JScrollPane(t);
f.getContentPane().add(s, BorderLayout.CENTER);
f.setTitle("coolman");
f.pack();
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
You’re question is a little vague. “Updating” a table model could be updating existing model (ie editing the data) and/or adding new rows.
I’ve done a quick example of both.
When editing a row, the model will and table will update them selves, so you needn’t do anything, however, if you add or remove rows, you will become responsible for firing the update events yourself.
You might like to have a read through How to use tables for more information