I have this code here, it’s a button that call another jFrame to edit stuff, the stuff goes into a jTable that need user input to update. I want to make this update automatic, by puting in the same button, but nothing hapens when I call the function that update the jTable, problably because the java machine don’t wait…
private void editarImovelActionPerformed(java.awt.event.ActionEvent evt) // Button {
int i = 0;
int linha = tabelaImoveis.getSelectedRow(); // tabelaImoveis = jTable
if (tabelaImoveis.isRowSelected(linha)) {
{
try {
Integer codigo = Integer.parseInt(tabelaImoveis.getValueAt(linha, 0).toString());
} catch (Exception e) {
mensagem.message("Linha sem Valor!");
i = 1;
} finally {
if (i == 0) {
Integer codigo = Integer.parseInt(tabelaImoveis.getValueAt(linha, 0).toString());
for (Imovel imovel : imovelLista) {
if (imovel.getCodigo() == codigo) { frmAlterar alterar = new frmAlterar();
alterar.setLocationRelativeTo(null);
alterar.setVisible(true);
alterar.setDefaultCloseOperation(alterar.DISPOSE_ON_CLOSE);
alterar.setarAtributos(imovel);
}
}
}
}
}
} else {
mensagem.message("Select Something!"); // Same as System.out...
}
updatejTable(); // This code here I want to execute after the frame "alterar" closes
}
The answer for this is the same as for all similar questions (and there are many): don’t use another JFrame, use a modal JDialog.