Results 1 to 6 of 6
Thread: Clickable links in a JTextPane?
- 10-14-2013, 03:33 AM #1
Member
- Join Date
- Oct 2013
- Posts
- 5
- Rep Power
- 0
Clickable links in a JTextPane?
Hi guys, I'm creating a text editor in JAVA and use the JTextPane to input the text. My problem is that I need to be able to input references that are clickable and want to avoid the usage of HTML. I created an object for each reference with the following information:
------
Title:
Description:
PathToFile:
-----
I want to display the title in the text as clickable but have no idea how to proceed? action listener ? mouse listener? ideas?
Thanks
- 10-14-2013, 02:37 PM #2
Re: Clickable links in a JTextPane?
want to avoid the usage of HTML
Do you want to write your own code to recognize where the click was made and to correlate that with some action.If you don't understand my response, don't ignore it, ask a question.
- 10-14-2013, 03:32 PM #3
Member
- Join Date
- Oct 2013
- Posts
- 5
- Rep Power
- 0
Re: Clickable links in a JTextPane?
Exactly, if there is no better way. The text editor will be used by reporters who want to have a lot of "references" to different files on the computer ex.
According to this file, the boy was shot in the head.
This magazine from 1990 shows that the suspect was innocent.
I was thinking abt doing JLables and listen for clicks on them, but dont know if that would work in a JTextArea. Every "reference" needs to be unique and have the information stated above in its object.
Any ideas?
- 10-14-2013, 05:01 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 26
Re: Clickable links in a JTextPane?
Look at JEditorPane or (probably) JTextPane, which is a subclass.
That handles hyperlinks, which is what you seem to be wanting, and you can attach a listener on those links.
I've not done it, so can't really help.
Here's the text component tutorial.Please do not ask for code as refusal often offends.
** This space for rent **
- 10-14-2013, 11:32 PM #5
Member
- Join Date
- Oct 2013
- Posts
- 5
- Rep Power
- 0
- 10-15-2013, 10:59 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 26
Re: Clickable links in a JTextPane?
?
Not sure what you mean.
You need to define exactly what it is you want, because it sounded like you simply wanted a way for people click on links.
If you want something to be clickable when someone is entering data then you'll need to describe how you expect the user to identify which bits of the stuff they're writing is something to be turned into a link.Please do not ask for code as refusal often offends.
** This space for rent **
Similar Threads
-
print the links just as plain text not as activated links !
By vector_ever in forum New To JavaReplies: 1Last Post: 08-24-2013, 07:22 PM -
JButton not clickable
By StevenTNorris in forum AWT / SwingReplies: 5Last Post: 11-09-2012, 09:59 PM -
Clickable image
By xtre in forum New To JavaReplies: 2Last Post: 09-08-2012, 02:56 PM -
Clickable text in a component
By kjkrum in forum AWT / SwingReplies: 3Last Post: 11-06-2011, 12:25 AM -
Double Clickable Application
By ellias2007 in forum Advanced JavaReplies: 7Last Post: 03-08-2010, 05:08 PM
Bookmarks