• 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how to activate html-links in a JEditor pane

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

loading and displaying a html-file in a JEditorPane works fine (see code snippet provided),
except for the functionality of html links.

Do I have to provide this functionality separately in a programmatical way, and if yes, how is it accomplished?

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API for JEditorPane has a code snippet on using HyperlinkListener
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the hint, that should do
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
common links work fine, but having a link referring to an email-adress like this:

results in the following exception:
java.net.UnknownServiceException: protocol doesn't support input

How can I achieve, that a JEditorPane invokes the default email program if clicking on that link?
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andy Jung wrote:results in the following exception:
java.net.UnknownServiceException: protocol doesn't support input


When? From your own code or from the API's code? Posting the stack trace may help.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it comes from Sun's API. Complete stack trace is:



I used exactly the code snippet from the JEditorPane-API Maneesh suggested.
 
Rob Spoor
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The setPage method does not work for mailto URLs.

In the HyperlinkListener get the protocol of the URL. If that is "mailto" don't call setPage but use Desktop.mail(URL) instead.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:
In the HyperlinkListener get the protocol of the URL. If that is "mailto" don't call setPage but use Desktop.mail(URL) instead.



Thanks, that works ! A very nice new 1.6-feature I didn't know before.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is there any API-constant specifiying the protocol "mailto" for html-links, so I don't have to hard-code this (see following code-snippet)?


reply
    Bookmark Topic Watch Topic
  • New Topic