title: Java, BorderLayout.CENTER, getting the width and height of the JPanel
body: <p>I am using Swing and AWT (for the listeners) to make a small program. I have a problem concerning getting the size of my JPanel (the class named Chess).
  My Layout:</p>
  
  <pre><code>public class Main extends JFrame implements MouseListener, ActionListener{
  
      Chess chessPanel = new Chess ();
      JButton newGameButton = new JButton ("New Game");
      JButton loadGameButton = new JButton ("Load Game");
      JButton saveGameButton = new JButton ("Save Game");
      JButton exitButton = new JButton ("Exit");
  
      public static void main (String [] args) {
          new Main();
      }
  
      Main () {
          super ("Chess");
          Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
          setSize(dim);
          setLocation(0,0);
          setUndecorated(true);
  
          chessPanel.addMouseListener(this);
          add(chessPanel, BorderLayout.CENTER);
  
          JPanel buttonPanel = new JPanel();
          buttonPanel.setLayout(new FlowLayout());
  
  
          newGameButton.addActionListener(this);
          loadGameButton.addActionListener(this);
          saveGameButton.addActionListener(this);
          exitButton.addActionListener(this);
  
          buttonPanel.add(newGameButton);
          buttonPanel.add(loadGameButton);
          buttonPanel.add(saveGameButton);
          buttonPanel.add(exitButton);
  
          add(buttonPanel, BorderLayout.SOUTH);
  
          setVisible(true);
      }
  
      // ... Code ...
  }
  </code></pre>
  
  <p>As you can see by the code, I have one JPanel in the CENTER, which takes nearly all the screen. In the bottom I have another JPanel (SOUTH), which has a row of buttons. </p>
  
  <p>What I need is the size that the JPanel in the CENTER takes. When I call the getWidth(), getHeight() or getBounds() methods inherited from JPanel, they all return 0, because of the BorderLayout. 
  Any idea how to get the real values?</p>
  
  <p>PS: The screen always takes up the entire screen, and will never be resized, if that helps.</p>