Article View: borland.public.jbuilder.java.swing
Article #140tried HTMLEditorKit.insertHTML after setPage
From: 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??
Technical Details
Message-ID:
<441902de$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 111d45,2e459dd5725bc754,start X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "ctskinner" <kelvinq415@yahoo.com> Sender: "ctskinner" <kelvinq415@yahoo.com> Reply-To: "ctskinner" <kelvinq415@yahoo.com> Subject: tried HTMLEditorKit.insertHTML after setPage Newsgroups: borland.public.jbuilder.java.swing X-User-Info: 220.101.175.189 NNTP-Posting-Host: 207.105.83.66 Message-ID: <441902de$1@newsgroups.borland.com> Date: 15 Mar 2006 22:17:02 -0700 X-Trace: newsgroups.borland.com 1142489822 207.105.83.66 (15 Mar 2006 22:17:02 -0700) Lines: 30 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail