cursor in jeditorpane

  • Follow


Clicking on a link in my JEditorPane causes a new page to be loaded
into the same pane with setText(). The problem is that the cursor
doesn't change; it's still the link cursor even when it's not over a
link in the new page. And if it is over a link, an entered hyperlink
event is only called when the mouse moves slightly.

Is there a (preferably easy) way to update the cursor properties when
the html page under it changes?

Any help is appreciated
-- Ricardo

0
Reply shstein2002 (4) 4/13/2005 12:42:31 AM

Hi,

Just pasting a part of the javadoc for JEditorPane.setText(...) which could
be interesting :

"The assumption is that the previous content is relatively small, and that
the previous content doesn't have side effects. Both of those assumptions
can be violated and cause undesirable results. To avoid this, create a new
document, getEditorKit().createDefaultDocument(), and replace the existing
Document with the new one. You are then assured the previous Document won't
have any lingering state. "

Regards,

Arnaud

<shstein2002@yahoo.com> a �crit dans le message news:
1113352951.466371.127690@o13g2000cwo.googlegroups.com...
> Clicking on a link in my JEditorPane causes a new page to be loaded
> into the same pane with setText(). The problem is that the cursor
> doesn't change; it's still the link cursor even when it's not over a
> link in the new page. And if it is over a link, an entered hyperlink
> event is only called when the mouse moves slightly.
>
> Is there a (preferably easy) way to update the cursor properties when
> the html page under it changes?
>
> Any help is appreciated
> -- Ricardo
>


0
Reply Arnaud 4/13/2005 7:32:51 AM


Alas, that doesn't do it. Here's my code, where centerkit is the editor
kit for centerpane:
<pre>
	public void setText(String s) {
		centerpane.setDocument(centerkit.createDefaultDocument());
		centerpane.setText(s);
	}
</pre>
Can you think of anything else I could try?

-- Ricardo

Arnaud Berger wrote:
> Hi,
>
> Just pasting a part of the javadoc for JEditorPane.setText(...) which
could
> be interesting :
>
> "The assumption is that the previous content is relatively small, and
that
> the previous content doesn't have side effects. Both of those
assumptions
> can be violated and cause undesirable results. To avoid this, create
a new
> document, getEditorKit().createDefaultDocument(), and replace the
existing
> Document with the new one. You are then assured the previous Document
won't
> have any lingering state. "
> 
> Regards,
> 
> Arnaud

0
Reply shstein2002 4/13/2005 2:27:20 PM

Hi,

What is your "HyperlinkListener" ?
Haven't you tried the one provided in JEditorPane's javadoc ?

Also setPage(..) will "maybe" do better.

Regards,

Arnaud

<shstein2002@yahoo.com> a �crit dans le message news:
1113402440.358000.84280@f14g2000cwb.googlegroups.com...
> Alas, that doesn't do it. Here's my code, where centerkit is the editor
> kit for centerpane:
> <pre>
> public void setText(String s) {
> centerpane.setDocument(centerkit.createDefaultDocument());
> centerpane.setText(s);
> }
> </pre>
> Can you think of anything else I could try?
>
> -- Ricardo
>
> Arnaud Berger wrote:
> > Hi,
> >
> > Just pasting a part of the javadoc for JEditorPane.setText(...) which
> could
> > be interesting :
> >
> > "The assumption is that the previous content is relatively small, and
> that
> > the previous content doesn't have side effects. Both of those
> assumptions
> > can be violated and cause undesirable results. To avoid this, create
> a new
> > document, getEditorKit().createDefaultDocument(), and replace the
> existing
> > Document with the new one. You are then assured the previous Document
> won't
> > have any lingering state. "
> >
> > Regards,
> >
> > Arnaud
>


0
Reply Arnaud 4/14/2005 6:29:23 AM

shstein2002@yahoo.com wrote:
> Clicking on a link in my JEditorPane causes a new page to be loaded
> into the same pane with setText(). The problem is that the cursor
> doesn't change; it's still the link cursor even when it's not over a
> link in the new page. And if it is over a link, an entered hyperlink
> event is only called when the mouse moves slightly.

The Hyperlink-related code in HTMLEditorKit does not react to any 
document-changes at all.

 
> Is there a (preferably easy) way to update the cursor properties when
> the html page under it changes?

Send the JEditorPane a bogus mouseMoved event.


Christian
0
Reply usenet 4/15/2005 11:17:01 PM

4 Replies
408 Views

(page loaded in 0.035 seconds)

Similiar Articles:













7/25/2012 7:24:30 PM


Reply: