title: Java: check if the mouse has clicked
body: <p>i am in trouble with checking if the mouse has clicked with a JFrame. When i use <code>public void mousePressed(MouseEvent e)</code> to print something and i click with the mouse it doesn't print anything. It doesn't gives a error, it just prints nothing out. Here is my code :</p>
  
  <pre><code>import java.awt.event.MouseEvent;
  import javax.swing.JFrame;
  import javax.swing.JScrollPane;
  import javax.swing.JTextArea;
  
  
  public class tuna extends JFrame
  {
  private JTextArea textArea;
  
  
  
  public static void main(String[] args)
  {
    //Run the program
  tuna run = new tuna();
  run.setDefaultCloseOperation(3);
  run.setSize(1200, 1000);
  
  run.setVisible(true);
  }
  
  public tuna()
  {
  
  
    super("Simple JFrame");
  
    //add a simple JScrollPane
    textArea = new JTextArea(10,10);
    JScrollPane scrollPane = new JScrollPane(textArea); 
    textArea.setEditable(true);
  
    add(scrollPane);
  
  }
  //This doesn't print anything when i am clicking in the JFrame
  public void mousePressed(MouseEvent e) 
  {
      if(e.getButton() == MouseEvent.BUTTON1)
      {
          System.out.println("left");
      }       
      else if(e.getButton() == MouseEvent.BUTTON3)
      {
        System.out.println("right");
      }
  }
  
  
  }
  </code></pre>
  
  <p>Thank you in advance.</p>