• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="+"[email protected]" +">"+"[email protected]"+ "</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 "[email protected] ".

Hint: Goto START->RUN-> type in run field "msimn.exe [email protected]"
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.
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic