title: Clearing text on mouse click from multiple JTextFields in Java
body: <p>I'm doing some error checking in two <code>JTextField</code>s. I'll label them <code>jtext1</code> and <code>jtext2</code>.</p>
  
  <p>Right now my GUI looks like this:</p>
  
  <pre><code>Enter number 1: [      ] // jtext1
  Enter number 2: [      ] // jtext2
  Convert         [ answer ]
  </code></pre>
  
  <p>I want to be able to check for multiple conditions and display an error message. For example, if the user enters nothing for both text fields, and hits convert the following should appear:</p>
  
  <pre><code>Enter number 1: [  Nothing entered    ] // jtext1
  Enter number 2: [  Nothing entered    ] // jtext2
  Convert         [ answer ]
  </code></pre>
  
  <p>And, if you use the mouse to click on <code>jtext1</code> I want it to clear the message so the user can enter a number. If they click on <code>jtext2</code> the same thing should also happen.</p>
  
  <p>So for example if I were to click on <code>jtext2</code> the following should appear:</p>
  
  <pre><code>Enter number 1: [  Nothing entered    ] // jtext1
  Enter number 2: [        ]              // jtext2
  Convert         [ answer ]
  </code></pre>
  
  <p>The problem is, with this piece of code:</p>
  
  <pre><code>if(!jtext1.isvalid()) {
      jtext1.setText("Nothing entered");
      jtext1.addMouseListener(new MouseAdapter(){
          @Override
          public void mouseClicked(MouseEvent e) {
              jtext1.setText("");
          }
      });
  }
  
  if(!jtext2.isvalid()) {
      jtext2.setText("Nothing entered");
      jtext2.addMouseListener(new MouseAdapter(){
          @Override
          public void mouseClicked(MouseEvent e) {
              jtext2.setText("");
          }
      });
  }
  </code></pre>
  
  <p>Only <code>jtext1</code> will work. This sort of makes sense to me, because I don't think I can keep overriding the same function, but how would I go around the issue?</p>