Como diz no titulo, estou tendo dificuldades para passar um objeto para outra classe.
CLASSE QUE PASSA OS VALORES PARA O OBJETO:
private void btnAlterarActionPerformed(java.awt.event.ActionEvent evt) {
if (jtblPesquisar.getSelectedRow() >= 0) {
Contato con = new Contato();
TelaAlterar jalterar = new TelaAlterar(this);
for (int i = 0; i <= jtblPesquisar.getSelectedRow(); i++) {
id = Long.valueOf((Integer) jtblPesquisar.getValueAt(i, 0));
nome = (String) jtblPesquisar.getValueAt(i, 1);
tel = (String) jtblPesquisar.getValueAt(i, 2);
email = (String) jtblPesquisar.getValueAt(i, 3);
con.setId(id);
con.setNome(nome);
con.setEmail(email);
con.setTelefone(tel);
}
jalterar.setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "Favor selecionar uma linha");
}
}
public void setContato(Contato c) {
this.c = c;
}
CLASSE QUE RECEBE OS VALORES DO OBJETO
public class TelaAlterar extends javax.swing.JFrame {
public TelaAlterar(TelaPesquisar tp) {
initComponents();
Contato c = new Contato();
txtNome.setText(tp.setContato(c.getNome()));
}
Não estou conseguindo conseguindo com que ele passe os valores selecionadas da tabela.