title: How to make an url inside a string clickable in gwt
body: <p>If I have a string like:</p>
  
  <pre><code>String textWithUrl = "I am a string and http://www.google.com is the url to google";
  </code></pre>
  
  <p>Then I put it in a HTML Element:</p>
  
  <pre><code>HTML html = new HTML(textWithUrl);
  </code></pre>
  
  <p>But the link is not clickable. Usually I make it clickable with (never tested it with a <code>Label</code>):</p>
  
  <pre><code>private String makeUrlInTextClickable(String text) {
  
      if (text == null) return "";
  
      String[] words = text.split(" ");
      String textWithUrl = text;
  
      for (String word : words) {
        // Maybe more checks are needed to prevent typos like abcdhttp://
        // Mostly the texts come from a source, in which the urls are likely to be valid
        if (word.toLowerCase().contains("http://")) textWithUrl = textWithUrl.replace(word, "&lt;a target=\"_blank\" href=\"" + word + "\"&gt;" + word + "&lt;/a&gt;");
      }
  
      return textWithUrl;
  }
  </code></pre>
  
  <p>The <code>textWithUrl</code> could be of any length with many urls inside.</p>
  
  <p>Is there a better way to do this?</p>
  
  <h3>Edit:</h3>
  
  <p>Example usage:</p>
  
  <pre><code>public class Test implements EntryPoint {
  
      @Override
      public void onModuleLoad() {
  
          String textWithUrl = "I am a string and http://www.google.com is the url to google";
          RootPanel.get().add(new HTML(makeUrlInTextClickable(textWithUrl)), 0, 0);
      }
  }
  </code></pre>
  
  <p>Output would be then just one HTML Widget with the clickable google url</p>