Java and the Internet: Introduction


We have by now covered most of the basic topics in the Java programming language. We have learned how to create stand-alone applications and applet, how to create our own reusable classes, how to incorporate threads into a program or applet, how to create simple graphics, and how to deal with exceptions (or errors).

Now we will start focusing on one of the issues that makes Java more powerful than most programming languages: network support. Java has contains classes that allow you to easily create programs that can read or write data from the Internet, or to create complete "client/server" solutions that enhance the features of a web browser. We have actually already seen one applet that deals with the Internet by itself: the "ChatterBox" applet that we use for our chat sessions.

In this sequence of lectures we will deal with:
manipulating the status bar of your web browser from inside a Java applet
getting your web browser to load and display a page on the web from inside an applet
loading an image into an applet
loading and playing a sound inside an applet
security restrictions that an applet is forced to obey
There are other network-related issues - such as reading and writting files accross the Internet - that we will deal in our next lecture(s).

The above possibilities are all built-in to the Applet class that we have been using for quite a while already. Here is the Java API for the Applet class:
public class Applet extends Panel
{   // Methods
    public void init();
    public void start();
    public void stop();

    public void showStatus(String  msg);
    public URL getCodeBase();
    public URL getDocumentBase();
    public AppletContext getAppletContext();
    public Image getImage(URL  url);
    public Image getImage(URL  url, String  name);
    public AudioClip getAudioClip(URL  url);
    public AudioClip getAudioClip(URL  url, String  name);
    public void play(URL  url);
    public void play(URL  url, String  name);
    public String getParameter(String  name);
}
We already know the first three methods, init(), start(), and stop(). In addition to those, however, the Applet class provides several other methods that can be used to display a status line, load a web page, load and display an image, load and play a sound, and obtain information from the HTML page that the applet is contained in.  Some more, related methods, are contained in the "AppletContext" class, which is defined as follows:
public  interface  AppletContext
{   // selected Methods
    public abstract void showDocument(URL  url);
    public abstract void showDocument(URL  url, String  target);
}
I have broken up these issues into several, small units .... starting with the easiest topic: manipulating the status bar of your web browser.


(bgw)