title: Reset ImageIcon location in JPanel
body: <p>I'm trying to make a new class for the enemy, but my head is in pain and I need help</p>
  
  <p>This is my Main, my game is like space invaders, but simpler, I want the enemy when I hit him with the laser to get lost and show up from a random y place in the right side of the Panel</p>
  
  <pre><code>public class GameMain extends JFrame  implements KeyListener , ActionListener{
  
   GamePanel panel;
   static int width = 1024 , height = 768;
   Timer t;
  
      public GameMain() {
          setTitle("Space Attack!!!");
          setLayout(null);
          setSize(width, height);
          setVisible(true);
  
          panel = new GamePanel();
          add(panel);
          panel.setBounds(1, 1 ,width, height);
          this.addKeyListener(this);
  
           Timer t = new Timer(40 , this);
              t.setInitialDelay(50);
              t.start(); 
      }
  
  public static void main(String[] args) {
          GameMain frame = new GameMain();
      }
  
  public void keyPressed(KeyEvent e) {
  
      int key = e.getKeyCode();
      if (key == (KeyEvent.VK_UP) &amp;&amp; GamePanel.y &gt; 1){
          GamePanel.y -= 10;
          GamePanel.ship.setLocation(GamePanel.x , GamePanel.y);
          }
          else if (key == (KeyEvent.VK_DOWN) &amp;&amp; GamePanel.y &lt; (height-55)){
              GamePanel.y += 10;
              GamePanel.ship.setLocation(GamePanel.x , GamePanel.y);
          }
          else if (key == (KeyEvent.VK_RIGHT) &amp;&amp; GamePanel.x &lt; (width-55)){
              GamePanel.x += 10;
              GamePanel.ship.setLocation(GamePanel.x , GamePanel.y);
          }
          else if (key == (KeyEvent.VK_LEFT) &amp;&amp; GamePanel.x &gt; 1){
              GamePanel.x -= 10;
              GamePanel.ship.setLocation(GamePanel.x , GamePanel.y);
          }
          if (key == (KeyEvent.VK_SPACE) ) {
              if (GamePanel.laser_x &lt;= GamePanel.x || GamePanel.laser_x &gt;= width){
              GamePanel.laser.setLocation(GamePanel.x+10 , GamePanel.y+20);
              GamePanel.laser_x = GamePanel.x +10;
              }
          }
  
      }
  
      public void keyReleased(KeyEvent e) {
      }
  
      public void keyTyped(KeyEvent e) {
      }
  
      public void actionPerformed(ActionEvent e) {
              GamePanel.en_x -= 15;
              GamePanel.enemy.setLocation(GamePanel.en_x ,GamePanel.en_y);
  
              GamePanel.laser_x += GamePanel.x+10;
              GamePanel.laser.setLocation(GamePanel.laser_x, GamePanel.y+20);
  </code></pre>
  
  <p>2nd Class that i use to add my JLabel</p>
  
  <pre><code>public class GamePanel extends JPanel {
      static JLabel space , ship ,enemy , laser;
      static int y = 384 , x = 80 , en_x = 950, en_y = 350, en_W = 9 , en_H = 1, laser_x ,laser_y;
  
  GamePanel(){
          setLayout(null);
  
          setSize(GameMain.width , GameMain.height);
          setBackground(Color.GRAY);
          setVisible(true);
          this.requestFocusInWindow();
          setFocusable(true);
          this.setFocusTraversalKeysEnabled(false);
  
  Laser
          ImageIcon icon4 = new ImageIcon("media/rsz_643x0w.jpg");
          laser = new JLabel(icon4);
          add(laser);
          laser.setBounds(laser_x, laser_y, en_W, en_H);
  
  
  enemy
          ImageIcon icon3 = new ImageIcon("media/rsz_250px-enemy_esports_logo.png");
          enemy = new JLabel(icon3);
          add(enemy);
          enemy.setBounds(en_x, en_y, 63, 63);
  
  Spaceship icon
          ImageIcon icon2 = new ImageIcon("media/asd.png");
          ship = new JLabel(icon2);
          add(ship);
          ship.setBounds(x, y, 50, 44);
  
          //Space icon
          ImageIcon icon1 = new ImageIcon("media/Wiki-background.jpg");
          space = new JLabel(icon1);
          add(space);
          space.setBounds(1, 1, GameMain.width, GameMain.height);
  
         }
  }
  </code></pre>