title: Add Same Array Of Buttons To Two JFrame's
body: <p>I am trying to add a array of buttons to two JFrame's to form a grid but when I try to do so the first JFrame has no buttons but the second time that i add the Buttons all the buttons are there.</p>
  
  <p><a href="https://i.stack.imgur.com/DEBHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DEBHE.png" alt="enter image description here"></a></p>
  
  <p>My code is</p>
  
  <pre><code>public class GUI
  {
      ReversiButton[][] reversi = new ReversiButton[8][8];
      JFrame WhiteFrame = new JFrame();
      JFrame BlackFrame = new JFrame();
      JLabel WhiteLabel = new JLabel();
      JLabel BlackLabel = new JLabel();
      JPanel BlackGrid = new JPanel();
      JPanel WhiteGrid = new JPanel();
      JButton WhiteButton = new JButton();
      JButton BlackButton = new JButton();
      public GUI()
      {
          populateArray();
          initGUI();
      }
      private void populateArray()
      {
          for(int y = 0;y&lt;8;y++)
          {
              for(int x = 0; x&lt;8;x++)
              {
                  reversi[x][y] = new ReversiButton();
              }
          }
      }
      private void initGUI()
      {
          WhiteFrame.setTitle("Reversi White Player");
          BlackFrame.setTitle("Reversi Black Player");
          WhiteFrame.setLayout(new BorderLayout());
          WhiteLabel.setText("White Player - click place to put piece");
          WhiteGrid.setLayout(new GridLayout(8,8));
          for(int wy = 0;wy&lt;8;wy++)
          {
              for(int wx = 0; wx&lt;8;wx++)
              {
                  WhiteGrid.add(reversi[wx][wy]);
              }
          }
          WhiteButton.setText("Greedy AI(play white)");
          WhiteFrame.add(BorderLayout.NORTH,WhiteLabel);
          WhiteFrame.add(BorderLayout.CENTER,WhiteGrid);
          WhiteFrame.add(BorderLayout.SOUTH,WhiteButton);
          WhiteFrame.pack();
          WhiteFrame.setVisible(true);
          BlackFrame.setLayout(new BorderLayout());
          BlackLabel.setText("Black player - not your turn");
          BlackGrid.setLayout(new GridLayout(8,8));
          for(int y = 0; y&lt;8; y++)
          {
              for(int x = 0; x&lt;8; x++)
              {
                  BlackGrid.add(reversi[x][y]);
              }
          }
          BlackButton.setText("Greedy AI(play black)");
          BlackFrame.add(BorderLayout.NORTH, BlackLabel);
          BlackFrame.add(BorderLayout.CENTER, BlackGrid);
          BlackFrame.add(BorderLayout.SOUTH,BlackButton);
          BlackFrame.pack();
          BlackFrame.setVisible(true);
      }
  }
  </code></pre>
  
  <p>How can I show the same array in two different JFrames?</p>