title: Manual Positioning of Image in JFrame
body: <p>I am trying to create a JFrame that displays an image from a file path onto a particular position on the JFrame. At a later time (when a button is clicked), I want the image to move positions, say, 50 pixles to the left. If a layout manager is necessary, I want to use the null layout, as this is a project for myself and I am not quite ready to learn how to write my own layout manager. </p>
  
  <p>So far, I have managed to display a BufferedImage in a frame, but I do not know how to specify its position. </p>
  
  <p>Is using a BufferedImage even the correct approach? What is the best way to go about doing this?</p>
  
  <p>Update: I tried to follow your suggestion of using mouselistener and it resulted in this: </p>
  
  <pre><code>class ImgComponent extends JComponent  implements ChangeListener, MouseListener  {
  
  MovableImage mi;
  
  public ImgComponent(MovableImage mi) {
      this.mi = mi;
      mi.addListener(this);
        mi.addListener1(this);
  }
  
  @Override
  protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.drawImage(mi.i, mi.getX(), mi.getY(), null);
  }
  
  @Override
  public void stateChanged(ChangeEvent e) {
      repaint();
  
  }
  @Override
  public void mouseClicked(MouseEvent e) {
          mi.setPos(100, 100);
          System.out.println("yay");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>But unfortinely, the mouseClicked event never triggers. I just want that damn image to move, lol.</p>