为什么我不能在JFrame中调用一个函数到另一个JFrame?

问题描述

我有JFrame 1名称Main一个功能

public void updateDataInTable(){
    //tb is table in JFrame 1
    tb.setRowCount(0);
    listemp = list.returnList();
    for(Employee i : listemp){
        tb.addRow(i.toObject());
    }
}

JFrame 2名称Add一个按钮:

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            // Todo add your handling code here:
            Main main = new Main();
            main.updateDataInTable();
        } catch (IOException ex) {
            Logger.getLogger(Add.class.getName()).log(Level.SEVERE,null,ex);
        }
        
       this.setVisible(false);
    }

但是当我单击JFrame 2中的按钮时,没有任何反应,updateDataInTable();调用,但是JFrame 1中的table并没有改变!你能解释为什么吗?并帮助我修复它,谢谢大家

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)