title: Moving and resizing JPanels object inside JFrame
body: <p>Continuing my quest of learning Java by doing a simple game, i stumbled upon a little issue. My gameboard extends JPanel as well as each piece of the board. Now, this presents some problems:</p>
  
  <ol>
  <li><p>Cant set size of each piece, therefore, each piece JPanel ocupy the whole JFrame, concealing the rest of the pieces and the background (gameboard).</p></li>
  <li><p>Cant set the position of the pieces.</p></li>
  </ol>
  
  <p>I have the default flow manager. Tried setbounds and no luck.</p>
  
  <p>Perhaps i should make the piece to extend other JComponent?
  Added image:
  That's the piece, now the greyed area is also the piece! Checked that by making a mousePressed listener and assigning some stuff to it. Below the grey area, is the gameboard (or at least, should be!), another JPanel.</p>
  
  <p><a href="http://img42.imageshack.us/img42/2227/screenshotvdy.png" rel="nofollow noreferrer">alt text http://img42.imageshack.us/img42/2227/screenshotvdy.png</a></p>
  
  <p>Some code:</p>
  
  <pre><code>package TheProject;
  
  import java.awt.Color;
  import java.awt.Dimension;
  
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  
  public class GameWindow extends JFrame {
  public GameWindow() {
      setSize(800, 600);
      setLocationRelativeTo(null);
      Map map = new Map(800, 600, 2);
      add(map);
  
      MilitaryUnit imperialRussia = new MilitaryUnit(30, Color.BLACK, Color.YELLOW, Color.WHITE);
      imperialRussia.setPreferredSize(new Dimension(30, 30));
      add(imperialRussia);
  
  }
   }
  </code></pre>
  
  <p>This happens when i apply the pack() method:
  <a href="http://img442.imageshack.us/img442/5813/screenshot2ml.png" rel="nofollow noreferrer">alt text http://img442.imageshack.us/img442/5813/screenshot2ml.png</a></p>
  
  <p>Packs around the Unit, not the map which is bigger and fills the JFrame.</p>