CroftSoft / Library / Tutorials / Java Swing Sprite Animation

Title | Applet | Background | AnimationCanvas | Resources


Background

Before Java became recognized as a useful server-side programming language for e-commerce applications, it was primarily used for web page animation and online games. A number of Internet startups and academic projects were launched to explore the possibilities of interactive entertainment distributed via the web using Java applets. From simple single player arcade games in 1995 to multiplayer persistent worlds in 1996, the nascent Java entertainment industry flourished.

While the cleverest Java programmers were always able to develop high performance applet games in Java, the 1996 Doom-style multiplayer first person shooter (FPS) "Fred" being a case in point, applet performance received a further boost with the widespread adoption of Just-In-Time (JIT) compilers. By early 1997, Java had effectively ceased to be an interpreted programming language as both of the dominant web browsers, Netscape Navigator and Microsoft Internet Explorer, included JIT technology which would automatically compile Java applet portable bytecode to client-specific native machine code upon download.

Some attribute the decline in industry interest in using Java for game development to performance issues. Many of these individuals are ignorant of JIT technology and assume that Java is still an interpreted programming language. As explained below, however, a more reliable interpretation points toward browser-based Java virtual machine standardization and distribution problems coupled with a drain of qualified Java applet developers to the lucrative server-side e-commerce and enterprise application industry.

Early versions of the Java standard defined a graphical user interface (GUI) application programming interface (API) library known as the Abstract Window Toolkit (AWT). Unfortunately, the AWT, as an initial attempt at providing a standardized Java GUI library, did not meet developer expectations when compared to GUI libraries available in other programming languages. The major browser vendors that supported Java applets responded by providing extension Java libraries that included feature-rich GUI APIs. These included the Netscape Internet Foundation Classes (IFC) for Netscape Navigator and the Microsoft Application Foundation Classes (AFC) for Internet Explorer.

Using these proprietary GUI libraries had a drawback, however, in that they created a vendor lock-in effect. As the IFC was only preinstalled with Netscape Navigator and the AFC was only preinstalled with Internet Explorer, the applets of developers that chose one API over the other did not run in the competing browser. While it was possible for these multi-megabyte Java extension libraries to be downloaded as needed along with the applet code to any browser where they were not already preinstalled, few users had the bandwidth to tolerate such a heavy download each time the applet was loaded.

To ensure that Java continued to be the Write Once Run Anywhere (WORA) portable programming language that would run in any browser from any vendor, JavaSoft introduced a standardized advanced GUI library, the Java Foundation Classes (JFC)/Swing API, initially defined and promoted within the Java 1.2 standard and as a Java 1.1 extension. The JFC/Swing classes effectively obsoleted many of the older GUI classes based upon the previous Abstract Window Toolkit (AWT) standard.

Microsoft, which by then had replaced Netscape as the dominant browser vendor by preinstalling a free version of Internet Explorer with each distribution of their Windows operating system, never did upgrade the Java virtual machine included with their browser to the Java 1.2 standard. As such, the JFC/Swing APIs included in Java 1.2 never became popular with developers for building applets. JavaSoft attempted to counter by releasing the Java Plug-In, formerly known as Activator, which would upgrade a client browser to the version of Java required by the applet. This effort was largely ignored by developers, however, as they and their management could not be convinced that the advantages to using the Java 1.2 APIs significantly outweighed the burden of upgrading the Java virtual machine on client browsers. Most browser users, still limited by low bandwidth connections, did not have the tolerance for even a one-time upgrade of their Java virtual machine if it required a multi-megabyte download. This effect was only exacerbated by emerging competition from Flash, an animation plug-in with a download of only a few hundred kilobytes.

As the Internet boom evolved, venture capital was redirected from client-side interactive entertainment content to server-side e-commerce applications. Java developers, with their skills honed from early efforts to create applet-based GUI applications, now found themselves in demand to build servlets. Free from the complications of client-side inconsistencies, the Java development community moved on. Java found a dominant niche in server-side deployment that persists to this day.

This trend from client-side Java development to server-side deployment is reflected in the literature. As the number of books published on all Java-related topics increased dramatically from year to year, the number of books on Java game programming and animation waned. With three books published specifically on the topic of Java game programming in 1996, this represented a significant percentage of the total number of Java-related books available at that time. While thousands of Java books have been published since then, the number of books published on Java game programming dropped to zero in 1999 with another book on that topic not being released until late 2001. Of those six Java game programming books published to date, including the latest book on Java 2 game development distributed just a few months ago, not one of them documents sprite animation using libraries more advanced than the Java 1.1 AWT classes. With the sole exception of the sprite animation tutorial posted at the JavaSoft web site, a review of the currently available body of online tutorials on the subject of Java sprite animation reveals a similar trend.

From recent industry announcements, it may be forecast that the time of Swing-based applets has finally come. After recently settling a lawsuit where it was determined that it would not be permitted to continue distributing adulterated versions of the Java 1.1 standard, Microsoft has announced that it will no longer preinstall any version of Java with Internet Explorer and its latest consumer operating system Windows XP. As it can no longer be assumed by developers and their management that a Java 1.1 virtual machine is preinstalled by default on most client machines, it is expected that applet developers will come to rely upon Java virtual machine installation validation tools such as the Java Plug-In and Java Web Start. This new requirement on developers to verify Java virtual machine installation may be a disguised blessing as the installation tools allows them to specify which version of Java is required for their applet or application. Developers, formerly bound to the constraints of Java 1.1 AWT applets, may now feel free to use the latest Java APIs including JFC/Swing.

This tutorial describes how to program sprite animation using a Java Swing component with a special emphasis on differences between older AWT-based sprite animation methods. In the process of introducing current methods of sprite animation, this tutorial introduces several reusable sprite classes which are available to the reader under the terms of an Open Source license.


Title | Applet | Background | AnimationCanvas | Resources

 
 
 
CroftSoft
 
 
-About
-Library
--Books
--Code
--Courses
--Links
--Media
--Tutorials
-People
-Portfolio
-Update
 
 
Google
CroftSoft Web
 

Creative Commons License
© 2005 CroftSoft Inc.
You may copy this webpage under the terms of the
Creative Commons Attribution License.