title: JButtons inside JPanels with a GridLayout JFrame
body: <p>I have one JFrame that is set to a GridLayout of size NxN. N is given by the user as a command line at the start of the program. JButtons in an NxN pattern are added to the window in JPanels, set in location by GridLayout (I think).</p>
  
  <p>Does each JButton need its own JPanel to use GridLayout? I'm under the impression that you can set up just  one JPanel for all the buttons and set the JPanel to a GridLayout for the JButtons. I want to add another JPanel to the left of the button array to display button clicks (JLabel) and a reset button within that same left JPanel.</p>
  
  <p>Here is (a little of) my code, where N is given by the user, system is my background processes class, and ButtonEvent is the class for ActionListener/actionPerformed:</p>
  
  <pre><code>JFrame window = new JFrame("");
  GridLayout layout = new GridLayout(N,N);
  window.setLayout(layout);
  
  for (int row = 0; row &lt; N; row++){
      for (int col = 0; col &lt; N; col++){
          JPanel panel = new JPanel();
          JButton b = new JButton ("("+row+","+col+")");
          window.add(b).setLocation(row, col);
          panel.add(b);
          b.addActionListener(new ButtonEvent(b, system, row, col));
          window.add(panel);
      }
  }
  
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.pack();
  window.setVisible(true);
  </code></pre>
  
  <p>And this is what I have (N=4):</p>
  
  <p><a href="https://i.imgur.com/nbQoM.png" rel="nofollow noreferrer">http://i.imgur.com/nbQoM.png</a></p>
  
  <p>Here is (approximately) what I am looking for (N=4):</p>
  
  <p><a href="https://i.imgur.com/SiVWO.png" rel="nofollow noreferrer">http://i.imgur.com/SiVWO.png</a></p>
  
  <p>All I need/want is two (or more) JPanels that are set up roughly like above, and all the layout managers I've tried don't play nice with the GridLayout layout JFrame.</p>