title: How to detect a click event in an Image class in Java?
body: <p>I'm practicing to learn Java by creating a simple game. In my simple game, I want to use the <a href="http://en.wikipedia.org/wiki/Abstract_Window_Toolkit" rel="nofollow">AWT</a> image class, and I want to click the image class, and it will pop up a dialog box like alert,</p>
  
  <pre><code>public class Sample
  {
      Image img = getImage(getClass().getResource("0.jpg"));
  
      void paint (Graphics g)
      {
          g.drawImage(img,30,30,this);
      }
  }
  </code></pre>
  
  <p>I want that if I clicked that image the image will detect the click event and it will show an alert dialog box.</p>