1
I have a JTextField
instantiated in the class time relay. By clicking on that JTextField
, he calls another JFrame
search.
When performing a search on this new JFrame
and click on Confirm, I need him to fill in the JTextField
first frame.
I tried in some ways, leaving the 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 the data by parameter
None of the attempts I made filled Jtextfield, how do I do that?
Call from the search screen:
private void txt_idMouseClicked(java.awt.event.MouseEvent evt) {
busca busca = new busca(null, rootPaneCheckingEnabled);
busca.setVisible(true);
}
Class search screen:
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);
}
}
Using Jdialog, instead of another Jframe, your problems are reduced by 90%. Post the search screen call and search screen class, which I can even suggest such a change in code.
– user28595
I edited, give a look @diegofm
– Vinicius Leonardo