title: Creating multiple identical text verify listeners in eclipse-rcp/swt
body: <p>I'm trying to validate the input of multiple text boxes (i.e. they should be a number), and found the useful code snippet below <a href="https://stackoverflow.com/questions/6451894/problem-with-validating-the-integer-value-in-java">here</a>.  </p>
  
  <p>However, if I have three text boxes (<code>text</code>, <code>moreText</code> and <code>evenMoreText</code>), how can I apply a verify listener with the same functionality to each, without having to repeat the (<code>.addVerifyListener(new VerifyListener() {...</code>) code three times?</p>
  
  <p>I don't want to implement a switch statement or similar (to decide which text box to apply it to), I want something more generic (that I can perhaps make available for other classes to use in the future).  </p>
  
  <pre><code>text.addVerifyListener(new VerifyListener() {
    @Override
    public void verifyText(VerifyEvent e) {
      final String oldS = text.getText();
      final String newS = oldS.substring(0, e.start) + e.text + oldS.substring(e.end);
  
      try {
        BigDecimal bd = new BigDecimal(newS);
        // value is decimal
        // Test value range
      } catch (final NumberFormatException numberFormatException) {
        // value is not decimal
        e.doit = false;
      }
    }
  });
  </code></pre>