🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages Started by smartnhandsome Wed, 18 Oct 2006 19:04
Problem in inserting text after hyperlink in JEditorPane
#199
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads