Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages
Started by ctskinner
Thu, 16 Mar 2006 05:17
tried HTMLEditorKit.insertHTML after setPage
Author: ctskinner
Date: Thu, 16 Mar 2006 05:17
Date: Thu, 16 Mar 2006 05:17
29 lines
1866 bytes
1866 bytes
I tried HTMLEditorKit.insertHTML after setPage, but zero length
This will load an html file into a JEditorPane:
JEditorPane ed = new JEditorPane();
ed.setEditable(true);
ed.setContentType("text/html"); // required??
HTMLEditorKit hkit = new HTMLEditorKit();
ed.setEditorKit(hkit);
HTMLDocument hdoc = (HTMLDocument) ed.getDocument();
this.getContentPane().add(new JScrollPane(ed));
String surl = "file:///C:\\a\\blah/doc/blah.html"
try {
ed.setPage(surl);
} catch (IOException e) {
JOptionPane.showMessageDialog(ed, new String[] {
"Unable to open file", surl }, "File Open Error",
JOptionPane.ERROR_MESSAGE);
System.out.println("Unable to open file" + surl);
} // catch
....................
BUT if I do
int j = hdoc.getLength();
I get zero length
and
hkit.insertHTML(hdoc, 184, "ZZZZZZZZZZZZZZ" ,0,0,Tag.BODY); fails
How do I insert text into an html file after it is loaded??
Re: tried HTMLEditorKit.insertHTML after setPage
Author: ctskinner
Date: Fri, 24 Mar 2006 04:49
Date: Fri, 24 Mar 2006 04:49
18 lines
1299 bytes
1299 bytes
More Limitations of JEditorPane as an HTML editor
if you load an html file then:
jep.setCaretPosition(3005); // throws a bad position exception
these 2 do nothing:
jep.setSelectionStart(2819);
jep.setSelectionEnd(3005);
these 2 lines have no effect
jep.setEditable(false); // or true
jep.setContentType("text/html");
Note: You can set a selection with the mouse, but not with the above functions.
Someone was lazy when they wrote this editor...
Re: tried HTMLEditorKit.insertHTML after setPage
Author: Lori M Olson [TeamB]
Date: Fri, 24 Mar 2006 16:39
Date: Fri, 24 Mar 2006 16:39
39 lines
2021 bytes
2021 bytes
ctskinner wrote:
> More Limitations of JEditorPane as an HTML editor
> if you load an html file then:
>
>
> jep.setCaretPosition(3005); // throws a bad position exception
>
> these 2 do nothing:
> jep.setSelectionStart(2819);
> jep.setSelectionEnd(3005);
>
> these 2 lines have no effect
> jep.setEditable(false); // or true
> jep.setContentType("text/html");
>
> Note: You can set a selection with the mouse, but not with the above functions.
>
> Someone was lazy when they wrote this editor...
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=312071
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
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