I have JTextField
instantiated in class rel_tempo . When you click this JTextField
, it calls another JFrame
of searches.
When I perform a search on this new JFrame
and click Confirm , I need to fill in the JTextField
of the first Frame.
I tried in some ways, leaving jtextfields public and with the following code:
relatorio.txt_id.setText(txt_id.getText());
I tried to create a method in the first JFrame where the JtextField is that receives by data parameter
None of the attempts I made filled the JTextField, how do I do this?
Search screen call:
private void txt_idMouseClicked(java.awt.event.MouseEvent evt) {
busca busca = new busca(null, rootPaneCheckingEnabled);
busca.setVisible(true);
}
Search screen class:
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Restrictions;
public class busca extends javax.swing.JDialog {
private List list_atendentes;
public busca(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
listar_pessoas();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Criteria crit_pessoa = session.createCriteria(Pessoa.class);
crit_pessoa.add(Restrictions.like("nome", "%"+txt_nome.getText()+"%"));
list_atendentes = crit_pessoa.list();
TableModelBusca tm = new TableModelBusca(list_atendentes);
table.setModel(tm);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
rel_tempo relatorio = new rel_tempo(null, rootPaneCheckingEnabled);
relatorio.txt_id.setText(txt_id.getText());
relatorio.txt_nome.setText(txt_nome.getText());
dispose();
}
public void listar_pessoas() throws HibernateException {
SessionFactory sf = new Configuration().configure().buildSessionFactory();
Session session = sf.openSession();
Criteria crit_motivo = session.createCriteria(Pessoa.class);
list_atendentes = crit_motivo.list();
TableModelBusca tm = new TableModelBusca(list_atendentes);
table.setModel(tm);
}
}