title: Updating an existing JFrame's components externally
body: <p>Here is the problem I'm running into - I have a GUI class implementing JFrame with a constructor that builds the Frame with 9 Panels in a 3x3 GridLayout. Each Panel is initialized in this constructor and have their own listeners, etc. However, there is a menu option to Load a file to display, but in order for me to be able to save/load files, I have a class dedicated to saving and loading. I've tested it out, and the problem lies in that when the load method in the save/load class is called, it creates a GUI object, hence re-making GUI components. When the GUI object is used to invoke a method called loadedFile in GUI (GUI.loadedFile), the program is supposed to set each JPanel to a certain RGB value background. However, it does not update my JPanel's backgrounds. Here is the part of constructor which initializes the panels and the loadedFile code:</p>
  
  <pre><code>A1 = new JPanel();
          A1.addMouseListener(mouseListener);
          A1.setBackground(Color.WHITE);
          add(A1);
      A2 = new JPanel();
          A2.addMouseListener(mouseListener);
          A2.setBackground(Color.WHITE);
          add(A2);
      A3 = new JPanel();
          A3.addMouseListener(mouseListener);
          A3.setBackground(Color.WHITE);
          add(A3);
      B1 = new JPanel();
          B1.addMouseListener(mouseListener);
          B1.setBackground(Color.WHITE);
          add(B1);
      B2 = new JPanel();
          B2.addMouseListener(mouseListener);
          B2.setBackground(Color.WHITE);
          add(B2);
      B3 = new JPanel();
          B3.addMouseListener(mouseListener);
          B3.setBackground(Color.WHITE);
          add(B3);
      C1 = new JPanel();
          C1.addMouseListener(mouseListener);
          C1.setBackground(Color.WHITE);
          add(C1);
      C2 = new JPanel();
          C2.addMouseListener(mouseListener);
          C2.setBackground(Color.WHITE);
          add(C2);
      C3 = new JPanel();
          C3.addMouseListener(mouseListener);
          C3.setBackground(Color.WHITE);
          add(C3);
      System.out.println("GUI() invoked");
  }
  </code></pre>
  
  <p>loadedFile:</p>
  
  <pre><code>public void loadedFile(int[] colors) {
      int counter = 0;
      //if in a different pain program using JPanels in an array for larger canvases,
      //use the JPanel[counter] set to colors[counter] for BG color. Also, enhanced
      //for loop could cycle through he values of panels array and set BG.
      A1.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      A2.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      A3.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      B1.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      B2.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      B3.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      C1.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      C2.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
          counter+=3;
      C3.setBackground(new Color(colors[counter], colors[counter+1], colors[counter+2]));
      System.out.println("BGS SET");
  }
  </code></pre>
  
  <p>Thanks in advance to anyone who can help!</p>