aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to make hyperlink to openup in browser and e-mail link in e-mail client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make hyperlink to openup in browser and e-mail link in e-mail client" Watch "How to make hyperlink to openup in browser and e-mail link in e-mail client" New topic
Author

How to make hyperlink to openup in browser and e-mail link in e-mail client

Raja Sekhara
Greenhorn

Joined: Dec 28, 2005
Posts: 6
I have one requirement to put a website address and e-mail address in a dialog, showing them like hyperlinks.

Say like adding hyperlink in JLabel.
1. new JLabel("<html><A href="+"http://www.javaranch.com" +">"+"http://www.javaranch.com"+ "</A></html>");

2. new JLabel("<html><A href="+"support@somemail.com" +">"+"support@somemail.com"+ "</A></html>");

In 1) when we click on hyper link it should open up website in clients default browser.
I would be able to do this by adding label to a button or just hyperlink text to button and writing code in actionPerformed method.

Is there any other easy way in API.

In 2) When clicked on e-mail hyperlink, it should open up in e-mail client, showing e-mail in to field of e-mail client.
For example, it should open up outlook and it should be like new message with to field filled with "support@somemail.com ".

Hint: Goto START->RUN-> type in run field "msimn.exe support@somemail.com"
This works if you have outlook installed in your system. But it opens outlook, not the new message with TO field filled with e-mail address mentioned.

I don't know how to implement this in code for my swing application.

Can any body know how to do this?

Thanks in advance.
Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hi Raja,

Check out the javax.swing.event.HyperlinkEvent class. It will give you a URL you can use to execute a command on the command line.

Darrin


Life is good on the Ponderosa,<br />but mind where you step.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make hyperlink to openup in browser and e-mail link in e-mail client
 
Similar Threads
JSplitPane, some help please
Open the same browser window from a hyperlink in email.
problem with images in web app
Does mailto open only outlook or default mail client
javax.mail Sender's Name