🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #199

Problem in inserting text after hyperlink in JEditorPane

#199
From: smartnhandsome
Date: Wed, 18 Oct 2006 19:04
35 lines
2259 bytes
Hi,

I have problem in inserting text after hyperlink in JEditorPane. I have
created a button to insert the link.

Steps:

1.Select the button.
2.Slect a node in the tree
3.release the button

then the hyperlink is created in the editor pane with the node's name.
After inserting the hyperlink I cannot write text after the created
hyperlink as the text newly enterred after the hyperlink also gets
included in the hyperlink. I need your help to set the style so that I
can enter any text after the hyper link as well.

int editcurrentSel = m_editor.getCaretPosition();
int p = m_editor.getCaretPosition();
AttributeSet attr = m_doc.getCharacterElement(p).getAttributes();

// First, setup the href attribute for <A> tag.
SimpleAttributeSet hrefAttr = new SimpleAttributeSet();
hrefAttr.addAttribute(HTML.Attribute.HREF, objectID);


// Second, setup the <A> tag
SimpleAttributeSet attrs = new SimpleAttributeSet();
attrs.addAttribute(HTML.Tag.A, hrefAttr);

m_doc.insertString(m_editor.getCaretPosition(),objectName, attr);
m_doc.setCharacterAttributes(editcurrentSel,objectName.length(), attrs,
false);

Thank you in advance
Technical Details
Message-ID: <1161198258.479959.228450@i42g2000cwa.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!i42g2000cwa.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,59795ea9183b0aa2,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!i42g2000cwa.googlegroups.com!not-for-mail
From: smartnhandsome@gmail.com
Newsgroups: borland.public.jbuilder.java.swing
Subject: Problem in inserting text after hyperlink in JEditorPane
Date: 18 Oct 2006 12:04:19 -0700
Organization: http://groups.google.com
Lines: 36
Message-ID: <1161198258.479959.228450@i42g2000cwa.googlegroups.com>
NNTP-Posting-Host: 70.232.2.246
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1161198264 25904 127.0.0.1 (18 Oct 2006 19:04:24 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 18 Oct 2006 19:04:24 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: i42g2000cwa.googlegroups.com; posting-host=70.232.2.246;
   posting-account=h5XVtw0AAADlpkU706bUcrCF4Db6Gghm