I have the following problem, I have 3 JFrames for several things, in the first one you enter data that is sent to the other 2 JFrames one to show the data in one table and the other to show the data in a graph, to the first I assign setVisible (true) and the second setVisible (false), my problem is that in the JFrame with the table I have a button that I thought would change the false of the graph to true to show it, but it always gives an error. do so or is there another way?
Code of the first JFrame
vr = new vent_resultado();
vr.setVisible(true);
vr.CargarInterfaz();
gt = new grafico();
for(int $i=1;$i<=Cant_Rep;$i++)
{
double ps = Porc_Sobr.generarDU();
double pf = Porc_Ferm.generarDU();
double pd = Porc_Desc.generarDN();
Viñedo = (Kil_Hec * Hec_Util) * (ps * 0.01);
Descarte = Viñedo * (pd * 0.01);
Seleccion = Viñedo - Descarte;
Fermentado = Seleccion * (pf * 0.01) * Tiem_Ferm;
Ferm_Espum = Seleccion * (pf * 0.01) * (Tiem_Ferm * 2);
Maduracion = Fermentado * (Lit * 0.01);
Mad_Espum = Ferm_Espum * (Lit * 0.01);
Vinos_Jov = Maduracion;
Vinos_Añe = Maduracion * (Porc_Cons * 0.01);
Vinos_Esp = Mad_Espum * (Porc_Cons * 0.01);
double de = Demanda_Esp.generarDN();
double dj = Demanda_Jov.generarDT();
double da = Demanda_Añe.generarDT();
Ing_Jov = Vinos_Jov * Precio_Jov * dj;
Ing_Añe = Vinos_Añe * Precio_Añe * da;
Ing_Esp = Vinos_Esp * Precio_Esp * de;
Ing_Totales = Ing_Jov + Ing_Añe + Ing_Esp;
Gastos_Jov = Vinos_Jov * Costo_Jov;
Gastos_Añe = Vinos_Añe * Costo_Añe;
Gastos_Esp = Vinos_Esp * Costo_Esp;
Gastos_Tot = Gastos_Jov + Gastos_Añe + Gastos_Esp + Costo_Fijo;
Ganan_Jov = Ing_Jov - Gastos_Jov;
Ganan_Añe = Ing_Añe - Gastos_Añe;
Ganan_Esp = Ing_Esp - Gastos_Esp;
Ganan_Tot = Ing_Totales - Gastos_Tot;
vr.mostrarDatos(Viñedo,Descarte,Seleccion,Fermentado,Ferm_Espum,Maduracion,Mad_Espum,Vinos_Jov,Vinos_Añe,Vinos_Esp,Ing_Jov,Ing_Añe,Ing_Esp,Ing_Totales,Gastos_Jov,Gastos_Añe,Gastos_Esp,Gastos_Tot,Ganan_Jov,Ganan_Añe,Ganan_Esp,Ganan_Tot,$i);
gt.graficar(Vinos_Jov,Vinos_Añe,Vinos_Esp,$i);
}
gt.setVisible(false);
this.dispose();
JFrame button code with the table
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
gt.setVisible(true);
}