title: clickable links in JOptionPane
body: <p>I'm using a JOptionPane to display some product information and need to add some links to web pages.</p>
  <p>I've figured out that you can use a JLabel containing html, so I have included an <code>&lt;a href&gt;</code> link. The link shows up blue and underlined in the dialog, however it is not clickable.</p>
  <p>For example, this should also work:</p>
  <pre><code>public static void main(String[] args) throws Throwable
  {
      JOptionPane.showMessageDialog(null, &quot;&lt;html&gt;&lt;a href=\&quot;http://google.com/\&quot;&gt;a link&lt;/a&gt;&lt;/html&gt;&quot;);
  }
  </code></pre>
  <p>How do I get clickable links within a JOptionPane?</p>
  <p>Thanks, Paul.</p>
  <p><strong>EDIT</strong> - eg solution</p>
  <pre><code>public static void main(String[] args) throws Throwable
  {
      // for copying style
      JLabel label = new JLabel();
      Font font = label.getFont();
  
      // create some css from the label's font
      StringBuffer style = new StringBuffer(&quot;font-family:&quot; + font.getFamily() + &quot;;&quot;);
      style.append(&quot;font-weight:&quot; + (font.isBold() ? &quot;bold&quot; : &quot;normal&quot;) + &quot;;&quot;);
      style.append(&quot;font-size:&quot; + font.getSize() + &quot;pt;&quot;);
  
      // html content
      JEditorPane ep = new JEditorPane(&quot;text/html&quot;, &quot;&lt;html&gt;&lt;body style=\&quot;&quot; + style + &quot;\&quot;&gt;&quot; //
              + &quot;some text, and &lt;a href=\&quot;http://google.com/\&quot;&gt;a link&lt;/a&gt;&quot; //
              + &quot;&lt;/body&gt;&lt;/html&gt;&quot;);
  
      // handle link events
      ep.addHyperlinkListener(new HyperlinkListener()
      {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e)
          {
              if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
                  Desktop.getDesktop().browse(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+
          }
      });
      ep.setEditable(false);
      ep.setBackground(label.getBackground());
  
      // show
      JOptionPane.showMessageDialog(null, ep);
  }
  </code></pre>