Clover coverage report - baseCode - 0.2.5 Coverage timestamp: Tue Apr 12 2005 11:31:58 EDT FRAMES NO FRAMES |
file stats: | LOC: | 96 |  | Methods: | 4
| NCLOC: | 79 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
JWebBrowser.java | 0% | 0% | 0% | 0% |

1 |  |
     package baseCode.gui;
2 |  |
3 |  |
     import java.awt.BorderLayout;
4 |  |
     import java.awt.Color;
5 |  |
     import java.awt.Dimension;
6 |  |
     import java.awt.event.ActionEvent;
7 |  |
     import java.awt.event.ActionListener;
8 |  |
     import java.io.IOException;
9 |  |
     import java.net.URL;
10 |  |
11 |  |
     import javax.swing.JEditorPane;
12 |  |
     import javax.swing.JFrame;
13 |  |
     import javax.swing.JLabel;
14 |  |
     import javax.swing.JPanel;
15 |  |
     import javax.swing.JScrollPane;
16 |  |
     import javax.swing.JTextField;
17 |  |
     import javax.swing.event.HyperlinkEvent;
18 |  |
     import javax.swing.event.HyperlinkListener;
19 |  |
20 |  |
     /**
21 |  |
      * @author Will Braynen;
22 |  |
      */
23 |  |
     public class JWebBrowser extends JFrame implements HyperlinkListener,
24 |  |
           ActionListener {
25 |  |
26 |  |
        private JTextField m_urlField;
27 |  |
        private JEditorPane m_htmlPane;
28 |  |
        private String m_initialURL;
29 |  |
30 | 0 |
        public static void main( String[] args ) {
31 | 0 |
           if ( args.length == 0 )
32 | 0 |
              new JWebBrowser( "http://microarray.genomecenter.columbia.edu/ermineJ" );
33 |  |
           else
34 | 0 |
              new JWebBrowser( args[0] );
35 |  |
        }
36 |  |
37 | 0 |
        public JWebBrowser( String initialURL ) {
38 | 0 |
           super( "Web Browser" );
39 | 0 |
           m_initialURL = initialURL;
40 |  |
41 | 0 |
           JPanel topPanel = new JPanel();
42 | 0 |
           topPanel.setBackground( Color.lightGray );
43 | 0 |
           JLabel urlLabel = new JLabel( "URL:" );
44 | 0 |
           m_urlField = new JTextField( 30 );
45 | 0 |
           m_urlField.setText( initialURL );
46 | 0 |
           m_urlField.addActionListener( this );
47 | 0 |
           topPanel.add( urlLabel );
48 | 0 |
           topPanel.add( m_urlField );
49 | 0 |
           getContentPane().add( topPanel, BorderLayout.NORTH );
50 |  |
51 | 0 |
           try {
52 | 0 |
              m_htmlPane = new JEditorPane( initialURL );
53 | 0 |
              m_htmlPane.setEditable( false );
54 | 0 |
              m_htmlPane.addHyperlinkListener( this );
55 | 0 |
              JScrollPane scrollPane = new JScrollPane( m_htmlPane );
56 | 0 |
              getContentPane().add( scrollPane, BorderLayout.CENTER );
57 |  |
           } catch ( IOException e ) {
58 | 0 |
              GuiUtil.error( "Can't build HTML pane for " + initialURL, e );
59 |  |
           }
60 |  |
61 | 0 |
           Dimension screenSize = getToolkit().getScreenSize();
62 | 0 |
           int width = screenSize.width * 8 / 10;
63 | 0 |
           int height = screenSize.height * 8 / 10;
64 | 0 |
           setBounds( width / 8, height / 8, width, height );
65 | 0 |
           setVisible( true );
66 |  |
        }
67 |  |
68 | 0 |
        public void actionPerformed( ActionEvent event ) {
69 | 0 |
           String url;
70 | 0 |
           if ( event.getSource() == m_urlField )
71 | 0 |
              url = m_urlField.getText();
72 |  |
           else
73 |  |
              // Clicked "home" button instead of entering URL (if we had a home button)
74 | 0 |
              url = m_initialURL;
75 | 0 |
           try {
76 | 0 |
              m_htmlPane.setPage( new URL( url ) );
77 | 0 |
              m_urlField.setText( url );
78 |  |
           } catch ( IOException e ) {
79 | 0 |
              GuiUtil.error( "Can't follow link to " + url, e );
80 |  |
           }
81 |  |
        }
82 |  |
83 | 0 |
        public void hyperlinkUpdate( HyperlinkEvent event ) {
84 | 0 |
           if ( event.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) {
85 | 0 |
              try {
86 | 0 |
                 m_htmlPane.setPage( event.getURL() );
87 | 0 |
                 m_urlField.setText( event.getURL().toExternalForm() );
88 |  |
              } catch ( IOException e ) {
89 | 0 |
                 GuiUtil.error( "Can't follow link to "
90 |  |
                       + event.getURL().toExternalForm(), e );
91 |  |
              }
92 |  |
           }
93 |  |
        }
94 |  |
     }
95 |  |
96 |  |