Clover coverage report -
Coverage timestamp: Sun Apr 18 2004 21:32:30 EDT
file stats: LOC: 102   Methods: 3
NCLOC: 68   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
HTMLDisplay.java 0% 86.1% 66.7% 80.5%
coverage coverage
 1   
 /*
 2   
  * HtmlDisplay.java
 3   
  *
 4   
  * Created on April 2, 2003, 10:13 PM
 5   
  */
 6   
 
 7   
 /**
 8   
  *
 9   
  * @author
 10   
  */
 11   
 
 12   
 import javax.swing.text.EditorKit;
 13   
 import java.net.URL;
 14   
 import java.util.*;
 15   
 import java.io.*;
 16   
 import java.awt.*;
 17   
 import javax.swing.event.*;
 18   
 import javax.swing.*;
 19   
 import javax.swing.text.html.*;
 20   
 import java.awt.event.ActionEvent;
 21   
 import java.awt.event.*;
 22   
 
 23   
 public class HTMLDisplay extends JFrame implements HyperlinkListener {
 24   
     JEditorPane jep;
 25   
     EditorKit htmlKit;
 26   
     JScrollPane scrollPane;
 27   
     JFrame f;
 28   
     
 29   
     
 30  2
     HTMLDisplay(File file, String t) {
 31  2
             jep = new JEditorPane();
 32  2
             jep.setEditable(false);
 33  2
             htmlKit = jep.getEditorKitForContentType("text/html");
 34  2
             HTMLDocument doc = (HTMLDocument) htmlKit.createDefaultDocument();
 35  2
             jep.setEditorKit(htmlKit);
 36  2
             jep.addHyperlinkListener( this );
 37  2
             try {
 38  2
                 URL u = file.toURL();
 39   
                 //InputStream in = u.openStream();
 40   
                 //jep.read(in, doc);
 41  2
                 jep.setPage(u);
 42   
             }
 43   
             catch (Exception e) {
 44  2
     JOptionPane.showMessageDialog(jep, "No Internet Connection", "Error", JOptionPane.ERROR_MESSAGE); 
 45   
             }
 46   
         
 47  2
             scrollPane = new JScrollPane(jep);
 48  2
             f = new JFrame(t);
 49  2
             f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 50  2
             f.getContentPane().add(scrollPane);
 51  2
             f.setSize(500, 500);
 52  2
             f.setVisible(true);
 53   
         
 54   
 
 55   
         }
 56   
     
 57   
     
 58   
 
 59   
     
 60   
     
 61  2
     HTMLDisplay(String s, String t) {
 62  2
         jep = new JEditorPane();
 63  2
         jep.setEditable(false);
 64  2
         htmlKit = jep.getEditorKitForContentType("text/html");
 65  2
         HTMLDocument doc = (HTMLDocument) htmlKit.createDefaultDocument();
 66  2
         jep.setEditorKit(htmlKit);
 67  2
         jep.addHyperlinkListener( this );
 68  2
         try {
 69  2
             URL u = new URL(s);
 70   
             
 71   
             //InputStream in = u.openStream();
 72   
             //jep.read(in, doc);
 73  2
             jep.setPage(u);
 74   
         }
 75   
         catch (Exception e) {
 76  0
 JOptionPane.showMessageDialog(jep, "No Internet Connection", "Error", JOptionPane.ERROR_MESSAGE); 
 77   
         }
 78   
         
 79  2
         scrollPane = new JScrollPane(jep);
 80  2
         f = new JFrame(t);
 81  2
         f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
 82  2
         f.getContentPane().add(scrollPane);
 83  2
         f.setSize(500, 500);
 84  2
         f.setVisible(true);
 85   
         
 86   
 
 87   
     }
 88   
     
 89  0
    public void hyperlinkUpdate(HyperlinkEvent event) {
 90  0
     if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
 91  0
       try {
 92  0
         jep.setPage(event.getURL());
 93   
       } catch(IOException ioe) {
 94  0
        System.err.println("Can't follow link to " 
 95   
                  + event.getURL().toExternalForm() + ": " + ioe);
 96   
       }
 97   
     }
 98   
   }
 99   
     
 100   
 }
 101   
 
 102