public class

AppletViewer

extends Frame
implements AppletContext Printable
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ java.awt.Window
         ↳ java.awt.Frame
           ↳ sun.applet.AppletViewer

Class Overview

The applet viewer makes it possible to run a Java applet without using a browser. For details on the syntax that appletviewer supports, see AppletViewer Tags. (The document named appletviewertags.html in the JDK's docs/tooldocs directory, once the JDK docs have been installed.)

Summary

[Expand]
Inherited Constants
From class java.awt.Frame
From class java.awt.Component
From interface java.awt.image.ImageObserver
From interface java.awt.print.Printable
Public Constructors
AppletViewer(int x, int y, URL doc, Hashtable atts, PrintStream statusMsgStream, AppletViewerFactory factory)
Create the applet viewer
Public Methods
MenuItem addMenuItem(Menu m, String s)
static int countApplets()
How many applets are running?
Applet getApplet(String name)
Get an applet by name.
Enumeration getApplets()
Return an enumeration of all the accessible applets on this page.
AudioClip getAudioClip(URL url)
Get an audio clip.
Image getImage(URL url)
Get an image.
InputStream getStream(String key)
Returns the stream to which specified key is associated within this applet context.
Iterator getStreamKeys()
Finds all the keys of the streams in this applet context.
static void main(String[] argv)
This method is deprecated. No replacement.
synchronized static void networkProperties()
static void parse(URL url, String enc)
Scan an html file for tags
static void parse(URL url)
static void parse(URL url, PrintStream statusMsgStream, AppletViewerFactory factory)
int print(Graphics graphics, PageFormat pf, int pageIndex)
Prints the page at the specified index into the specified Graphics context in the specified format.
static void printTag(PrintStream out, Hashtable atts)
Print the HTML tag.
void processUserAction(ActionEvent evt)
Handle events.
static String scanIdentifier(Reader in)
Scan identifier
static Hashtable scanTag(Reader in)
Scan tag
void setStream(String key, InputStream stream)
Associates the specified stream with the specified key in this applet context.
void showDocument(URL url)
Ignore.
void showDocument(URL url, String target)
Ignore.
void showStatus(String status)
Show status.
static void skipSpace(Reader in)
Scan spaces.
void updateAtts()
Make sure the atrributes are uptodate.
Protected Methods
void appletQuit()
Quit all viewers.
[Expand]
Inherited Methods
From class java.awt.Frame
From class java.awt.Window
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.applet.AppletContext
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface java.awt.print.Printable
From interface javax.accessibility.Accessible

Public Constructors

public AppletViewer (int x, int y, URL doc, Hashtable atts, PrintStream statusMsgStream, AppletViewerFactory factory)

Create the applet viewer

Public Methods

public MenuItem addMenuItem (Menu m, String s)

public static int countApplets ()

How many applets are running?

public Applet getApplet (String name)

Get an applet by name.

Parameters
name an applet name.
Returns
  • the applet with the given name, or null if not found.

public Enumeration getApplets ()

Return an enumeration of all the accessible applets on this page.

Returns
  • an enumeration of all applets in the document represented by this applet context.

public AudioClip getAudioClip (URL url)

Get an audio clip.

Parameters
url an absolute URL giving the location of the audio clip.
Returns
  • the audio clip at the specified URL.

public Image getImage (URL url)

Get an image.

Parameters
url an absolute URL giving the location of the image.
Returns
  • the image at the specified URL.

public InputStream getStream (String key)

Returns the stream to which specified key is associated within this applet context. Returns null if the applet context contains no stream for this key.

For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one codebase cannot access the streams created by an applet from a different codebase

Parameters
key key whose associated stream is to be returned.
Returns
  • the stream to which this applet context maps the key

public Iterator getStreamKeys ()

Finds all the keys of the streams in this applet context.

For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one codebase cannot access the streams created by an applet from a different codebase

Returns
  • an Iterator of all the names of the streams in this applet context.

public static void main (String[] argv)

This method is deprecated.
No replacement.

Old main entry point.

public static synchronized void networkProperties ()

public static void parse (URL url, String enc)

Scan an html file for tags

Throws
IOException

public static void parse (URL url)

Throws
IOException

public static void parse (URL url, PrintStream statusMsgStream, AppletViewerFactory factory)

Throws
IOException

public int print (Graphics graphics, PageFormat pf, int pageIndex)

Prints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException.

Parameters
graphics the context into which the page is drawn
pf the size and orientation of the page being drawn
pageIndex the zero based index of the page to be drawn
Returns
  • PAGE_EXISTS if the page is rendered successfully or NO_SUCH_PAGE if pageIndex specifies a non-existent page.

public static void printTag (PrintStream out, Hashtable atts)

Print the HTML tag.

public void processUserAction (ActionEvent evt)

Handle events.

public static String scanIdentifier (Reader in)

Scan identifier

Throws
IOException

public static Hashtable scanTag (Reader in)

Scan tag

Throws
IOException

public void setStream (String key, InputStream stream)

Associates the specified stream with the specified key in this applet context. If the applet context previously contained a mapping for this key, the old value is replaced.

For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one codebase cannot access the streams created by an applet from a different codebase

Parameters
key key with which the specified value is to be associated.
stream stream to be associated with the specified key. If this parameter is null, the specified key is removed in this applet context.
Throws
IOException

public void showDocument (URL url)

Ignore.

Parameters
url an absolute URL giving the location of the document.

public void showDocument (URL url, String target)

Ignore.

Parameters
url an absolute URL giving the location of the document.
target a String indicating where to display the page.

public void showStatus (String status)

Show status.

Parameters
status a string to display in the status window.

public static void skipSpace (Reader in)

Scan spaces.

Throws
IOException

public void updateAtts ()

Make sure the atrributes are uptodate.

Protected Methods

protected void appletQuit ()

Quit all viewers. Shutdown all viewers properly then exit from the program (if not stand alone)