Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2008, 03:48 PM
Member
 
Join Date: May 2008
Posts: 7
olbion is on a distinguished road
[SOLVED] hyperlinks in JTextPane
Hi,

I have a java applet with a JTextPane component, to which text is added like this:
<code>
textPane = new JTextPane();
doc = textPane.getStyledDocument();
doc.insertString(doc.getLength(), message, doc.getStyle(style));
</code>

What I would like is to be able to add hyperlinks to this text, such that clicking one of them will bring up a separate browser window, in which one url or another will load. I know that the way to achieve the browser window is to use
<code>
getAppletContext().showDocument(userUrl,target)
</code>

What I don't know is how to connect a string added to the JTextPane to such a method. Is this at all possible? Or would I need to use components such as labels rather than strings to achieve it? The drawback that I see with such a solution is that it would not be possible to highlight/select text.

Thank you very much for your help
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-01-2008, 11:18 PM
Member
 
Join Date: May 2008
Posts: 6
lonelyShoes is on a distinguished road
Have you seen the documentation on Sun's website about Editor Panes? If you are just asking how to mark up text inside the pane with HTML, then that article should answer your questions.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-02-2008, 06:12 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yep, using the JEdiotrPane you can easily catch the URL from the HTML text. It's too easy.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-04-2008, 12:42 AM
Member
 
Join Date: May 2008
Posts: 7
olbion is on a distinguished road
Thank you very much for pointing me in the right direction. With the JEditorPane and a HyperlinkListener, my problem was solved.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-05-2008, 05:28 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Nice to here that pal. So, please mark thread as solved form the thread tools menu.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to show a html document on JTextPane mary Advanced Java 2 08-02-2007 03:40 PM
how to insert tables into JTextPane osval AWT / Swing 1 07-29-2007 11:11 AM
hyperlinks from menu items? asterope118 New To Java 1 07-16-2007 03:49 PM
Transparent JTextPane Ada AWT / Swing 1 05-31-2007 11:50 PM


All times are GMT +3. The time now is 05:57 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org