Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 89   Methods: 7
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleApplet.java 0% 0% 0% 0%
coverage
 1   
 package example;
 2   
 
 3   
 import java.applet.Applet;
 4   
 import java.awt.*;
 5   
 import java.awt.event.*;
 6   
 
 7   
 /** A very simple AWT-based applet.  See applet.xml and applet.hmlt.<p>
 8   
     <blockquote><code><pre>
 9   
     &lt;applet code="example.SimpleApplet" width=250 height&gt;
 10   
     &lt;/applet&gt;
 11   
     </pre></code></blockquote>
 12   
     <p>
 13   
     @author kelvinr@users.sourceforge.net, twall@users.sourceforge.net
 14   
  */
 15   
 
 16   
 public class SimpleApplet extends Applet { 
 17   
 
 18   
     String msg = "This is a simple applet"; 
 19   
 
 20  0
     public void init() { 
 21  0
         Label push = new Label("Press a button"); 
 22  0
         final Button hi = new Button("High"); 
 23  0
         final Button lo = new Button("Low"); 
 24  0
         final Button show = new Button("?");
 25  0
         Component parent = this;
 26  0
         while (parent.getParent() != null) {
 27  0
             parent = parent.getParent();
 28   
         }
 29  0
         if (!(parent instanceof Frame))
 30  0
             parent = new Frame("Dummy Frame");
 31  0
         final Dialog dialog = new Dialog((Frame)parent, "Dialog", true);
 32  0
         dialog.add(new Label("This is a dialog"));
 33  0
         dialog.addWindowListener(new WindowAdapter() {
 34  0
             public void windowClosing(WindowEvent we) {
 35  0
                 we.getWindow().hide();
 36   
             }
 37   
         });
 38   
         
 39   
         // Adds labels and buttons to applet window 
 40  0
         add(push); 
 41  0
         add(hi); 
 42  0
         add(lo); 
 43  0
         add(show);
 44  0
         add(new TextField("text here"));
 45   
 
 46  0
         ActionListener al = new ActionListener() {
 47  0
             public void actionPerformed(ActionEvent ae) { 
 48  0
                 if (ae.getSource() == hi) {
 49  0
                     msg = "Up, up and away!"; 
 50   
                 } 
 51  0
                 else if (ae.getSource() == lo) {
 52  0
                     msg = "How low can you go?"; 
 53   
                 } 
 54   
                 else {
 55  0
                     dialog.pack();
 56  0
                     dialog.show();
 57   
                 }
 58  0
                 repaint(); 
 59   
             }
 60   
         };
 61  0
         hi.addActionListener(al); 
 62  0
         lo.addActionListener(al); 
 63  0
         show.addActionListener(al);
 64   
 
 65  0
         tagThread("applet init");
 66  0
         javax.swing.SwingUtilities.invokeLater(new Runnable() {
 67  0
             public void run() {
 68  0
                 tagThread("example.SimpleApplet");
 69   
             }
 70   
         });
 71   
     } 
 72   
 
 73  0
     private void tagThread(String tag) {
 74  0
         Thread thread = Thread.currentThread();
 75  0
         String name = thread.getName();
 76  0
         thread.setName(name + " (" + tag + ")");
 77   
     }
 78   
 
 79  0
     public String getMessage() {
 80  0
         return msg;
 81   
     }
 82   
 
 83  0
     public void paint(Graphics g) { 
 84  0
         g.drawString(getMessage(), 20, 120); 
 85   
     } 
 86   
 
 87   
 } 
 88   
 
 89