Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Display problem in JEditorPane

Thread view: 
Michael Jung - 23 Jun 2007 21:33 GMT
I have the following problems, someone may already have experienced or knows
how to solve.

I have a JEditorPane that contains an HTMLDocument, which contains some
referenced images, i.e. <img>-tags.  Now, I'd like to display this in Graphics
context that is not the GUI (where everything works fine).

The problem is that immediately after I load the document, the images seem not
to be available for drawing.  This fits with the fact that the GUI elements on
screen get redrawn as images get loaded successively.  However, I cannot find
a proper event to listen to, that tells me that the JEditorPane is finished
drawing.  I also can't find anything at the HTMLDocument, but I presume that
would be the wrong object anyway.

Additionally there may be a problem that simple drawing of the JEditorPane
without actually "showing" it, might not convince that component to draw the
images at all.  I have experimented a little with the
SwingUtilities.paintComponent to circumvent this but it apparently didn't
help.

Thanks,
Michael
hiwa - 23 Jun 2007 23:37 GMT
> I have the following problems, someone may already have experienced or knows
> how to solve.
[quoted text clipped - 18 lines]
> Thanks,
> Michael

public class HTMLEditorKit2 extends HTMLEditorKit{
 public Document createDefaultDocument(){
   HTMLDocument doc = (HTMLDocument)(super.createDefaultDocument());
   doc.setAsynchronousLoadPriority(-1); //do synchronous load
   return doc;
 }
}
------------------------------------------
JEditorPane.registerEditorKitForContentType("text/html",
"HTMLEditorKit2");
JEditorPane jep = new JEditorPane();
jep.setEditorKitForContentType("text/html", new HTMLEditorKit2());
Michael Jung - 24 Jun 2007 20:01 GMT
> > I have a JEditorPane that contains an HTMLDocument, which contains some
> > referenced images, i.e. <img>-tags.  Now, I'd like to display this in
[quoted text clipped - 12 lines]
> > SwingUtilities.paintComponent to circumvent this but it apparently didn't
> > help.

> public class HTMLEditorKit2 extends HTMLEditorKit{
>   public Document createDefaultDocument(){
[quoted text clipped - 8 lines]
> JEditorPane jep = new JEditorPane();
> jep.setEditorKitForContentType("text/html", new HTMLEditorKit2());

Doesn't help. It speeds up the drawing, but it's not fast enough (apparently).
I'm not sure this should really do the trick, because the GUI loading also
still shows some lag.

That also makes sense, since displaying an HTML document depends on the
size/layout of the JEditorPane itself, which can vary during time, while the
loading of the document happens only once.

[Technically, I'm not using any difficult layout in the document, but the
possibility should show that the HTML layout is a seperate process from the
document loading, which is now synchronous.]

I hope there is something about the JEditorPane that tells me when the doc is
fully layed out, since the GUI Layout manager somehow knows (I hope).

Michael
Roedy Green - 29 Jun 2007 14:45 GMT
>I hope there is something about the JEditorPane that tells me when the doc is
>fully layed out, since the GUI Layout manager somehow knows (I hope).

The HTML rendering inside Java is pretty Mickey Mouse.  Perhaps you
needa more powerful rendering engine. see
http://mindprod.com/jgloss/htmlrendering.html

If you have a masochistic streak, you might consider rendering the
images yourself on a separate layer and somehow jostling them around
to render over top of the mangled images produced by Java.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Michael Jung - 30 Jun 2007 16:06 GMT
[...]
> >I hope there is something about the JEditorPane that tells me when the doc is
> >fully layed out, since the GUI Layout manager somehow knows (I hope).
> The HTML rendering inside Java is pretty Mickey Mouse.  Perhaps you
> needa more powerful rendering engine. see
> http://mindprod.com/jgloss/htmlrendering.html

I don't see the point. It's not the rendering I have problems with. It's that
I don't know when it's finished.

Michael


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.