Applet Browser

I've created a fully functioning AppletViewer-like application, called AppletBrowser (which we'll cover later in detail). AppletBr owser implements the needed stub and context. We're going to use it in our interactive sessions.

Import JApp let, and create an instance of it.

>>> from javax.swing import JApplet >>> applet = JApplet()

ImportAppletBr owser, and create an instance of it.

>>> from AppletBrowser import AppletBrowser >>> browser = AppletBrowser()

Add the applet instance to AppletBrowser to simulate its loading into AppletViewer or another Java-enabled browser.

>>> browser.addApplet(applet)

Get the color parameter from the applee.

>>> color = applet.getParameter("color")


Get the hello parameter from the applet

>>> hello = applet.getParameter("hello") >>> print hello "hi mom"

The other parameters—codebase,code,archive, and so forth—which aren't defined by the param keyword, arre accessible through applet. getParameter ().

Getarchive,code, and codebase from the applet, and print them out.

>>> code = applet.getParameter("code") >>> codebase = applet.getParameter("codebase") >>> archive = applet.getParameter("archive") >>> print (code, codebase, archive)

('com.awl.j ava_book.MyApplet', './jpywork/', '..\..\lib\j ython.jar')

Try to get a parameter that doesn't e xist. getParameter () will return None.

>>> print applet.getParameter("my_param") None

Use parameters to pass informatio n, such as the URL and driver name om the datyb ase to which the appiet connects, or the COS naming service where it looka for its stubs. Basically, the applet's parameters customize its behavior.

Was this article helpful?

0 0

Post a comment