title: How to use multiple instances of a JFrame and access variables from another JFrame form
body: <p>I am making a sudoku game, in which I have two separate JFrame forms i.e., Home.java and Avg_Game.java
  I have made two instances of Avg_Game class in Avg_Game JFrame form.
  One instance is used to get variable "Player" from Home.java Jframe and another is to generate sudoku within Avg_Game file.
  Now the problem is if I just run the Avg_Game.java file then i it just generate sudoku and don't access the variable "Player" from another Jframe ....... and if I run Home.java file and open Avg_Game Jframe using a button on Home.java file then it is just access variable "Player" but not generates sudoku.But I want both should work...PLease help</p>
  
  <p>/* in Avg_Game.java */</p>
  
  <pre><code>public class Avg_Game extends javax.swing.JFrame {
  public Avg_Game() {     
  }
  
  public  Avg_Game(String Om) { 
           pop = Om;
           initComponents();
  
  }
  String pop;
  JFrame frame = new JFrame();
  
  int[] mat[];
  int[] mat_sol[];
  int n,sqn,k;
  
  public Avg_Game(int n,int k) {
      this.n = n;
      this.k = k;
  
      Double sqnd = Math.sqrt(n);
      sqn = sqnd.intValue();
      mat = new int[n][n];
              initComponents();
      }
  </code></pre>
  
  <p>..........</p>
  
  <p>..........</p>
  
  <p>// in main</p>
  
  <pre><code>public static void main(){
  
  java.awt.EventQueue.invokeLater(new Runnable() {
  
  public void run() {
  
              new Avg_Game(n,k).setVisible(true);
          }
      });      
  }
  </code></pre>
  
  <p>/*in Home.java */</p>
  
  <pre><code>Avg_Game average = new Avg_Game(Player); 
  
  average.setVisible(true);
  </code></pre>