title: How can I place a JLabel on a specific position within a JFrame?
body: <p>We're about to create an online based Space Invaders-game with implemented graphics. I've been reading about JFrames, JPanels and JLabels in order to create a window with a grid where the ships and monsters will be placed in.</p>
  
  <p>So, here's the thing, I've been looking through the different layouts that exists, but nothing really seems to fit our purpose. I would like a simple JFrame with the possibility of placing JLabel-objects on a certain position (with setBounds(), setLocation() or something similar). This requires setLayout(null) which I've heard isn't a good solution? I was thinking of having objects in a fixed 30x30px size, and a fixed window size of 600x600px (giving me a grid of 20*20).</p>
  
  <p>Anyhow, I've been trying to get it to work with setLayout(null), but without any results. If I apply a layout, say FlowLayout, the ship is visible, but stuck in either LEFT, CENTER or MIDDLE.</p>
  
  <pre><code>public class GUI extends JFrame {
  
      JPanel p = new JPanel(null);
  
      public GUI() {
  
          try{
              this.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("graphics/bg.png")))));
          }catch(IOException e) {
          System.out.println("Image does not exist");
          }
  
          this.setLayout(null);
          this.setResizable(false);
          this.setSize(600,600);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setLocationRelativeTo(null);
          this.setVisible(true);
      }
  
      public void placeShip1() {
          ImageIcon ship2 = new ImageIcon("graphics/ship2.png");
          JLabel imageLabel = new JLabel(ship2);
  
          imageLabel.setBounds(200,200,30,30);
          p.add(imageLabel);
          p.setOpaque(false);
          p.setSize(600, 600);
  
          this.add(p);
          this.setVisible(true);
      }   
  }
  </code></pre>
  
  <p>I really can't see why it doesn't work. I mean, all I want is my JFrame with a background image and with an object on a certain position, but instead the object doesn't show at all.</p>
  
  <p>The main reason for wanting to use setLayout(null) is because I was thinking of using a method translating our grid coordinates to the JFrame, simply mapping each coordinate to respective cell. </p>