What I'm doing is a little longer, so I'll shorten the problem with a more objective example:
I have a registration form and created a modal Jdialog with the fields that I want to search. When I search in JDialog I would like to filter the information in the table that is in the JFrame. The problem is that it is not working.
VISAO (Search Screen):
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
FrmCadUsuarios frm = new FrmCadUsuarios();
frm.tbVisivel(true);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
FrmCadUsuarios frm = new FrmCadUsuarios();
frm.tbVisivel(false);
}
VISAO (registration form):
public class FrmCadUsuarios extends javax.swing.JFrame {
private JTable tbUsuarios;
DefaultTableModel modelo = new DefaultTableModel();
public FrmCadUsuarios() {
initComponents();
this.setLocation(550,250);
criaTabela();
jScrollPane1.setViewportView(tbUsuarios);
}
public void tbVisivel (boolean aa) {
tbUsuarios.setVisible(aa);
}
}
I call JDialog
like this:
private void tb_btn_pesquisarActionPerformed(java.awt.event.ActionEvent evt) {
frmPesquisa pesq = new frmPesquisa(this,false);
pesq.setVisible(true);
}
And I try to update a JLabel
on the screen of main
so it has 2 buttons, 1 should make the label visible and the other invisible:
private void btn2ActionPerformed(java.awt.event.ActionEvent evt) {
FrmCadUsuarios frm = new FrmCadUsuarios();
frm.tbVisivel(this, true);
}
private void btn3ActionPerformed(java.awt.event.ActionEvent evt) {
FrmCadUsuarios frm = new FrmCadUsuarios();
frm.tbVisivel(this, false);
}
The form search builder ( JDialog
) looks like this:
public frmPesquisa(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.setLocation(1300,100);
}