| Andreas Rozek |
|
Placeholder AppletApplets are separate entities on a web page, with their own graphics context that does not "inherit" any visual properties of an applet's environment. Sometimes, however, a more "seamless" integration into the enclosing HTML document might be preferrable in order to hide the fact that a certain functionality is not provided by the browser itself but by a separate Java applet. The "Placeholder" applet demonstrates how to make an applet "invisible" by adopting the background texture of the underlying web page. Please note, that this approach is not really "fool proof" (depending on the actual texture) and might require some "fine tuning", as the layout mechanisms of different web browsers may vary considerably. Technical DescriptionThe underlying technique of this applet is extremely simple: assuming that the actual web page uses a bitmap texture to draw the background, the applet just uses the same texture file to fill its own display area. As a result, web page and applet look the same and - in the ideal case - the applet's border disappears. (Note: on web pages without a background texture, the same effect can be achieved by simply adopting the page's background color) Applet ParametersAny necessary information such as the URL of the texture file and any geometric displacements (for a better "fit" of the background texture) are passed as applet parameters:
A typical invocation of the "Placeholder" applet may therefore look as follows: <APPLET code=Placeholder.class width=300 height=200>
<PARAM name="Background" value="./Textures/Paper.jpg">
<PARAM name="XOffset" value="0"><PARAM name="YOffset" value="0">
</APPLET>
Example
Source CodeThe source code of this applet is available for download:
|
| http://www.Andreas-Rozek.de/Java/Applets/Placeholder.html | (last Modification: 23.04.2002) |