how to use JEditorPane/JTextPane? My JTextPane/JEditorPane is not working

507 views Asked by At

In a swing application I have a JFrame and by Dragging a JTextPane on that Jframe But when I try to show html content it does not seem to work properly.

Here is what I'm trying

JEditorPane ep = jp;    //jp is JTextPane.

        ep.setContentType("text/html");
//        ep.setText(text);
        URL u = null;
        try {
            u = new URL("http://www.google.com");
        } catch (MalformedURLException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            ep.setPage(u);
        } catch (IOException ex) {
            Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

And here is its result Here is the result

Actually I first tried with my own html string code with its setText(); method that html was working in browser and the result in java was not satisfactory then I tried to open google page that is in front of you.

It seems that the the basic html is working but styles and scripts are not working. So please tell me to use it well.
Thanks

0

There are 0 answers