An example of reading HTML directly

     JEditorPane jep = new JEditorPane();
     jep.setEditable(false);   
     EditorKit htmlKit = jep.getEditorKitForContentType("text/html");
     HTMLDocument doc = (HTMLDocument) htmlKit.createDefaultDocument();
     jep.setEditorKit(htmlKit);
     
     try {
       URL u = new URL("http://www.macfaq.com");
       InputStream in = u.openStream();
       jep.read(in, doc);
     }
     catch (IOException e) {
       System.err.println(e);
     } 
      
     JScrollPane scrollPane = new JScrollPane(jep);     
     JFrame f = new JFrame("Macfaq");
     f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     f.getContentPane().add(scrollPane);
     f.setSize(512, 342);
     f.show();

Previous | Next | Top | Cafe au Lait

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 28, 2000