title: Adding toolbar to GUI in JAVA
body: <p>I am working on chess game. I have JFrame where I've container, which include 2d array of JLabel fields. Now i would like to add to my window a toolbar, but when i want to do that, my chessboard crumble. This is a picture how my window with chessboard look like <a href="http://i.stack.imgur.com/co1cb.jpg" rel="nofollow">Window</a>. I want to add toolbar on the top of the window, where i can for example save/load game ...etc
  Also I would like to add to the right side some panel where i can see previous moves. I would like to know how to do that without destroying my chessboard.
  Here is my code:</p>
  
  <pre><code>public class GUI extends JFrame implements Serializable{
   public void initGUI() {
      setTitle("Chess game");
      setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
      ImageIcon img = new ImageIcon("pieceImages/whiteKing.png");
      contentPane = getContentPane();
      GridLayout gridLayout = new GridLayout(8, 8);
      contentPane.setLayout(gridLayout);
      for (int i = 0; i &lt; 8; i++) {
          for (int j = 0; j &lt; 8; j++) {
              labels[i][j]=new JLabel(game.getBoard()[i][j].getImagePath());
              contentPane.add(labels[i][j]);
          }
      }
      setIconImage(img.getImage());
      setResizable(false);
      setSize(600, 600);
      setLocationRelativeTo(null);
      setVisible(true);
  }
  </code></pre>
  
  <p>I created suggestion of some JPanel how it would look like:</p>
  
  <pre><code>public class Toolbar extends JPanel implements Serializable {
     public Toolbar(){
         JButton newGameBtn = new JButton("New game");
         JButton regretBtn = new JButton("Regret move");
         add(newGameBtn);
         add(regretBtn);
     }
  }
  </code></pre>