集册 Java实例教程 使浏览器访问URL

使浏览器访问URL

欢马劈雪     最近更新时间:2020-01-02 10:19:05

475
使浏览器访问URL


import java.applet.Applet;

import java.awt.Graphics;
/*
时 代      J a v a   公   众 号 - nowjava.com 提供
*/

import java.net.MalformedURLException;

import java.net.URL;


class BasicApplet extends Applet {

  // This method is called once by the browser when it starts the applet.

  public void init() {

    try {

      URL url = new URL(getDocumentBase(), "http://hostname.com/page.html");

      getAppletContext().showDocument(url);

    } catch (MalformedURLException e) {

    }

  }


  // This method is called whenever the page containing this applet is made

  // visible.

  public void start() {/** from N o w J a v a . c o m - 时代Java**/

  }


  // This method is called whenever the page containing this applet is not

  // visible.

  public void stop() {

  }


  // This method is called once when the browser destroys this applet.

  
展开阅读全文