magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2000 > 05 > Java@Work  

Scripting Applets Pays Off

By Al Williams

When you want to add client-side functionality to a Web site you have to make a choice: applets or JavaScript. Then again, do you? Java applets are powerful, but compared to JavaScript they're hard to develop and modify. On the other hand, some jobs are tough to code using script.

Why not partition your task so you can use an applet in conjunction with a script? Then you can incorporate the best parts of each technology.

To illustrate this idea, I've put together an applet designed to work with a script. The applet simulates a pair of dice. Since that's all it does, you could use it for a variety of Web sites. The example this month is a simple craps game (see Figure 1). However, you could easily create a variety of casino games, board games, or even role-playing games. If you don't like games, you can apply the same techniques to more serious applets.

Besides communicating with a script, the example applet also illustrates other interesting techniques. For example, the applet has to synchronize two threads and generate random numbers.

The Power of Applets

There are several reasons to roll functions into an applet:
  • Some functions are easier to create in regular Java than in JavaScript.
  • It may be possible to perform operations in Java that would otherwise require capabilities (like DHTML) that are not as widely supported as Java applets.



  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2