File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes href in JOptionPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "href in JOptionPane" Watch "href in JOptionPane" New topic

href in JOptionPane

Ken Clark

Joined: Aug 02, 2004
Posts: 11
I've created a JOptionPane and am formatting the text using <html> tags. I'm able to add a link to a web site via the <a href="">Go Here</a>, and it shows up as a link in the JOptionPane. The problem is that nothing happens when I click on the link.
Do I need to create a MouseListener make this happen?

code snippet:

String message = "<html><center>";
message += "<p>Some text";
message += "<p><a href=\"\">Yahoo</a>";
message += "</center></html>";

JOptionPane.showMessageDialog(this, message, "Info", JOptionPane.INFORMATION_MESSAGE);
I agree. Here's the link:
subject: href in JOptionPane