• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2272
  • Last Modified:

How to insert a hyperlink text in a JOptionPane component ?

hello

I'm using the following code :
JOptionPane.showMessageDialog(frame, "To use our software go to the url http://www.google.com");

I'd like to use a hyperlink text.
What is the correct code ?

Thanks

Regards

AC
              
0
pofpof98
Asked:
pofpof98
  • 3
  • 3
2 Solutions
 
CEHJCommented:
Try just using normal html
0
 
CEHJCommented:
If that doesn't work use a JEditPane with a HyperlinkListener in the code or a label with a MouseListener
0
 
CEHJCommented:
You can adapt this so it's a JDialog:


http://www.java2s.com/Code/JavaAPI/javax.swing/JEditorPanesetPageURLurl.htm

or fit it into a JPanel and add that to your JOptionPane
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ksivananthCommented:
also check the below link and the MHyperlinkLabel,

http://macrotracker.mozdev.org/developers_toolkit.php
0
 
ksivananthCommented:
and the other option is to use JDIC browser component where in you need not worry about hyper link listener, the component will take care of openening the link in another browser window!

https://jdic.dev.java.net/
0
 
ksivananthCommented:
here is an simple JLable impl for openening the link in browser window,

String link = "http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=forum&f=2";
JLabel label = new JLabel("<html><u>"+link+"</u></html>",JLabel.CENTER);
label.addMouseListener(new MouseAdapter(){      
  public void mousePressed(MouseEvent me){        
     try{
         Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+link);
     }catch(Exception e){e.printStackTrace();}      
  }    
});

you can add this lable to a JDIalog and show as CEHJ told!
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now