// A program that is a simple WWW browser.
// Barry Cornelius, 30th January 2000
import java.awt.    BorderLayout;
import java.awt.    Container;
import java.io.     IOException;
import javax.swing. JButton;
import javax.swing. JEditorPane;
import javax.swing. JFrame;
import javax.swing. JScrollPane;
import javax.swing. JTextField;
import java.util.   Properties;

public class Browser
{
   public static void main(final String[] pArgs)
   {
      // you will need to uncomment the following three statements
      // if your access to the WWW is through a proxy machine
      // you will have to replace proxymachine.sitename.com
      // and 8080 with appropriate values for your site
      // final Properties tProperties = System.getProperties();
      // tProperties.put("http.proxyHost", "proxymachine.sitename.com");
      // tProperties.put("http.proxyPort", "8080");
      final String tFirstURLString =
               "http://www.dur.ac.uk/understanding.java/";
      JEditorPane tJEditorPane = new JEditorPane();
      tJEditorPane.setContentType("text/html");
      tJEditorPane.setEditable(false);
      final JTextField tStatusJTextField = new JTextField("");
      final JTextField tURLJTextField = new JTextField(tFirstURLString);
      final PagesHandler tPagesHandler =
               new PagesHandler(tJEditorPane, tURLJTextField);
      final HTMLListener tHTMLListener =
               new HTMLListener(tPagesHandler, tStatusJTextField);
      tJEditorPane.addHyperlinkListener(tHTMLListener);
      final JScrollPane tJScrollPane = new JScrollPane(tJEditorPane);
      final URLJTextFieldListener tURLJTextFieldListener =
               new URLJTextFieldListener(tPagesHandler, tURLJTextField);
      tURLJTextField.addActionListener(tURLJTextFieldListener);
      final JFrame tJFrame = new JFrame("Browser");
      final Container tContentPane = tJFrame.getContentPane();
      final ExitOnWindowClosing tExitOnWindowClosing =
               new ExitOnWindowClosing();
      tJFrame.addWindowListener(tExitOnWindowClosing);
      tContentPane.add(tURLJTextField,    BorderLayout.NORTH);
      tContentPane.add(tJScrollPane,      BorderLayout.CENTER);
      tContentPane.add(tStatusJTextField, BorderLayout.SOUTH);
      tJFrame.setLocation(100, 100);
      tJFrame.setSize(500, 300);
      tJFrame.setVisible(true);
      tPagesHandler.setPage(tFirstURLString);
   }
}

