Bridging the Communications Gap
By Al Williams
The Internet is all about communications, right? So why is it that most Java applets lead solitary lives? What could you do with Java applets that could talk to other applets? How about communicating back to the server? It's possible to make both kinds of applets with a minimum of fuss by using the AppletContext object from inside your applet.
This month I'll show you how to create applets that can cooperate with each other and simply communicate with the server. Along the way, you'll see a few tricks for handling fonts, and disabling layout managers.
Take a look at
Figure 1. This Web page contains two different applets and some HTML. The first applet displays one of several palindromes (phrases that spell the same forwards or backwards). The second applet looks like a regular form button, but it signals the first applet to advance to the next palindrome. If the first applet realizes it has run out of palindromes, it signals the server to load a new Web page (presumably one with more palindromes). The applet also displays a custom status message in the browser's status bar. Just for fun, I put a second copy of the first applet at the bottom of the page.
The AppletContext
All of this is possible because of the AppletContext interface (see