JEditorpane, unable to insert or switch content type using the htmleditorkit -> bug?

G

Gerrit Hulleman

I have created an HTML editor applet using the JEditorpane. But there are
some random features. Most of the time the applet runs fine, but often it
shows odd behaviour.

Sometimes, the applet can be used, but it fails to go to plain text mode
using the code below. Also, a break tag (amongst other things) can no longer
be inserted. Using system.out I can confirm that all the code is processed
and no exceptions are thrown. Clearing the cache and reloading the applet
results in the correct working yet again.

Is this a bug do to the current developement state of the jeditorpane?

Gerrit

switch to plain text mode:
String htmltext = htmledit.getEditor().getText();
htmledit.getEditor().setEditorKit(htmledit.getEditor().getEditorKitForConten
tType("text/plain"));
htmledit.getEditor().setText(htmltext);

Inserting a <br> tag:
if (ChangeEditorType.getInstance(htmledit).isHTMLstate()){
try {
HTMLEditorKit kit = (HTMLEditorKit) htmledit.getEditor().getEditorKit();
HTMLDocument doc = (HTMLDocument) htmledit.getEditor().getDocument();
kit.insertHTML(doc, htmledit.getEditor().getCaretPosition(), "<br>", 0,
0, HTML.Tag.BR);
} catch (Exception e) { .... }
} else {
//in text state
.........
}
 
A

Andrew Thompson

I have created an HTML editor applet using
the JEditorpane. But there are some random
features. Most of the time the applet runs fine..

I wish I had a dollar for every time someone
mentioned an applet but no URL..

( ..No Gerrit, it is not a specific comment
about this post ..way past my bed time and
applets swimming around in my head.. ;-)

[ BTW I suspect the JEditorPane itself *is*
the cause of the problem, but there are others
who have wrestled with it in a lot greater
detail than I have.. ]
 
R

Roedy Green

I wish I had a dollar for every time someone
mentioned an applet but no URL..

We need some sort of Johnny Carson Carnak the Magnificient routine to
poke fun at how people expect you to diagnose problems without seeing
the code.

It reminds me a small statue used by ancient Chinese physicians. Women
would point to the part of the body they were having trouble with. It
was considered unseemly for the doctor to actually examine the patient
directly.
 
G

Gerrit Hulleman

My apologies about the no-url part. At my current location I have no access
to an internet site. Going through some problems, but I managed to get it up
at http://tenba.no-ip.com/applet/index_cb.html

Note: the applet is signed, only for system clipboard access for copy/paste
features. You have only my word that it does nothing more, but not accepting
only limits access of the applet to the clipboard and should not have any
effect on the bug mentioned in my first message.

The bugs seems to happen (amongst other situations like long idle periods)
sometimes when the applet is reloaded from cache.

Hope this helps, and hope even more you can help me again ^^

Gerrit

Andrew Thompson said:
I have created an HTML editor applet using
the JEditorpane. But there are some random
features. Most of the time the applet runs fine..

I wish I had a dollar for every time someone
mentioned an applet but no URL..

( ..No Gerrit, it is not a specific comment
about this post ..way past my bed time and
applets swimming around in my head.. ;-)

[ BTW I suspect the JEditorPane itself *is*
the cause of the problem, but there are others
who have wrestled with it in a lot greater
detail than I have.. ]

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,853
Latest member
GeorgiaSta

Latest Threads

Top