View HTML inside Applet without using JEditorPane

I have a small (500kb) swing applet that displays a very simple / limited set of small HTML pages inside it using a JEditorPane, however it doesn't seem to run 100% smoothly, some clients get a blank page rendered without any Java exceptions ... The page works fine from my machine. I need a more reliable way to show the HTML page to all our users.

Any ideas if a small + free class is used instead of the JEditorPane class OR there is an easy fix to make it more robust (not empty)

private JEditorPane m_editorPane = new JTextPane();


    m_editorPane.setEditable( false);

    m_editorPane.setBackground(new Color(239  ,255, 215));
    m_editorPane.setBounds(30,42,520,478 );
    m_editorPane.setDoubleBuffered(true);
    m_editorPane.setBorder(null);

    m_editorPane.registerEditorKitForContentType("text/html", "com.xxxxx.SynchronousHTMLEditorKit");


m_editorPane.setPage(ResourceLoader.getURLforDataFile(param.trim())); 

      

+1


source to share


3 answers


AFAIK, JEditorPane is a very primitive HTML component: it's confused about CSS and doesn't know anything about JS.
I doubt you will find that the small + free class works better, parsing and displaying HTML is not an easy business, much less today.



It may be better to let the big names in business take care of this task, i.e. using Internet Explorer or Mozilla components (whichever is available, etc.): JDIC: Embedding a Web Browser in Java .

+1


source


While I haven't used it before, Lobo is an open source web browser for Java with support for HTML 4, Javascript, and CSS 2.



Compared to JEditorPane

which only supports HTML 3.2, it looks like Lobo could be a better bet for loading modern web pages.

+2


source


I have recently released some java HTML rendering solutions. We decided on JEditorPane because we really need to minimize the size of our jar and embed it in Swing. However, the best library I've come across was Flying Saucer . It doesn't have js support, but the rendering quality and api are a cut, and it's "free" (LGLP), 100% Java and only about 1MB (still too big for us, but small compared to other options). However, it only renders strict XHTML (all attribute values โ€‹โ€‹must be specified, all tags are well formed), but that might be OK depending on your needs (and HtmlCleaner or some other utility like this might help with that).

0


source







All Articles