FileDocCategorySizeDatePackage
URLViewer.javaAPI DocExample1793Sun Mar 28 19:06:04 BST 1999None

URLViewer

public class URLViewer extends Frame implements WindowListener, ActionListener

Fields Summary
TextField
theURL
Button
loadButton
StreamedTextArea
theDisplay
Constructors Summary
public URLViewer()

  
    
    super("URL Viewer");
  
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent evt)

  
    try {
      URL u = new URL(theURL.getText());
      InputStream in = u.openStream();
      OutputStream out = theDisplay.getOutputStream();
      StreamCopier.copy(in, out);
      in.close();
      out.close();
    }
    catch (MalformedURLException ex) {
      theDisplay.setText("Invalid URL");
    }
    catch (IOException ex) {
      theDisplay.setText("Invalid URL");
    }
  
  
public voidinit()

  
    this.add("North", theURL);
    this.add("Center", theDisplay);
    Panel south = new Panel();
    south.add(loadButton);
    this.add("South", south);
    theURL.addActionListener(this);
    loadButton.addActionListener(this);
    this.addWindowListener(this);
    this.setLocation(50, 50);
    this.pack();
    this.show();
    
  
public static voidmain(java.lang.String[] args)


    URLViewer me = new URLViewer();
    me.init();

  
public voidwindowActivated(java.awt.event.WindowEvent e)

public voidwindowClosed(java.awt.event.WindowEvent e)

public voidwindowClosing(java.awt.event.WindowEvent e)

  
    this.setVisible(false);
    this.dispose();
  
  
public voidwindowDeactivated(java.awt.event.WindowEvent e)

public voidwindowDeiconified(java.awt.event.WindowEvent e)

public voidwindowIconified(java.awt.event.WindowEvent e)

public voidwindowOpened(java.awt.event.WindowEvent e)