Today's lead Java Today item is Jeff Friesen's "Happy Holidays" post, in which he describes the code behind his JFXStudio Holiday Challenge winning JavaFX application. The application was created with JavaFX 1.2 (via NetBeans IDE 6.5.1) on top of Java SE 6u16.
Here's Jeff's description of his app:
Happy Holidays presents a scene where snowflakes fall into a snowbank while "Let It Snow! Let It Snow! Let It Snow!" (the classic 1945 Christmas song by lyricist Sammy Cahn and composer Jule Styne) plays. When the music ends, Figure 1's logo fades into view.
Note that if you are on a Linux system, the app may not run. It loads, but then hangs on my Gentoo and Ubuntu Linux systems after I "Click to start." On my Mac and Windows machines it works fine.
JFXStudio Challenge contests impose a limit of 30 lines of JavaFX code and 3000 total characters. Jeff met this challenge by submitting a Main.fx consisting of a single 2996-character line, with variable names shortened to the point where their meaning would be unclear to all but the original developer. In his post, however, Jeff presents the original code, with standardized formatting and meaningful variable names. The original code is also divided into two files, Main.fx and Snowflake.fx.
The code includes some structures that reflect Jeff's original more ambitious plans for the application -- plans which subsequently had to be abandoned to meet the 3000-character Challenge limit. For example:
Perhaps you're curious about the color: Color.WHITE
assignment -- aren't snowflakes always white? Although they're
always white in this version of the program, I initially planned
to color snowflakes white and various shades of gray to make the
snowfall more realistic. Specifically, I planned to render larger (closer) snowflakes in
front of smaller (more distant) snowflakes, and color smaller
snowflakes in darker shades of gray (based on radius).
While the moving snowflakes are what stands out as you watch the app run, making that happen doesn't really occupy that much code. Really, much of the code in Main.fx involves creating the scene and managing the progression of the app from start to finish. For example, there is code for start-up (the animation doesn't begin until the user clicks the background image), and post-animation code (after the music stops, a "Happy Holidays" logo fades into view). Snowflake.fx manages the creation of the snowflakes, each of which consists of six branches, each with sub-branches.
Jeff closes by providing the downloadable code and challenging us to take the app further:
Now that you've explored Happy Holidays, you might want to improve this application by adding a more realistic snowfall (as discussed earlier), displaying a glowing moon in front of the background, scrolling the song's lyrics across the screen while it plays, and so on. Have fun!
Earlier this month I entered the JFXStudio Holiday Challenge with "Happy Holidays" as my submission. Figure 1 reveals this JavaFX application's scene. Happy Holidays presents a scene where snowflakes fall into a snowbank while "Let It Snow! Let It Snow! Let It Snow!" (the classic 1945 Christmas song by lyricist Sammy Cahn and composer Jule Styne) plays. When the music ends, Figure 1's logo fades into view...
Kenai.com hosts a NetBeans Platform based implementation of the Campbell Prediction System (CPS), which helps manage and predict the behavior of wildland fire. CPS is described as being used to adjust tactics and strategies to ensure the safety of firefighters and the effective use of resources. I've seen this CPS implementation on Kenai before, but a lot of development seems to have been taking place in the past few weeks and so I downloaded it to have a look. A lot of work is going into the project, with project lead Bruce Schubert's @Emxsys twitter link being an interesting one to follow...
There are many articles and tutorials out there that discuss how to use the individual technologies in Java EE 6, e.g., JSF 2, EJB 3.1, JPA, etc, to develop an application, but I haven't seen one that puts together the said technologies and showcases them in one tutorial with an end-to-end demonstration. As such, I thought I would create one here for the benefit of those who are new to JEE6 and NetBeans IDE 6.8 and those who are seriously looking at NetBeans IDE 6.8 as a tool for developing their enterprise applications. This article aims to provide detailed steps to develop a web-based application based on technologies in the JEE6 specs...
As I happily wrote about new features of JSF 2.0, my coauthor David Geary kept asking me how to run the examples in Tomcat 6. I kept putting it off—hunting down all those JAR files and web.xml fragments is just too much like eating soup with a fork. I finally got around to doing the research and thought that others might benefit from the (unhappy) results, if only to realize that this may be the time for switching to GlassFish...
Cargo is a versatile library that lets you manage, and deploy applications to, a variety of application servers. In this article, we look at how to use Cargo with Maven. If you are starting from scratch, you can use an Archetype to create a Cargo-enabled web application...
Here's another simple example of how the as(...) idiom can be used for create an API which is stable, elegant, but extensible (this time unrelated to any semantic stuff). Up to a few days ago, I had the following interface in the GeoCoding API of forceTen...
In the Forums, xinxindolphin needs help with a project run in wonderland error: "When I share my own NETBEANS in wonderland,I run my project,but it give me wrong messages: Xlib: extension "Generic Event Extension" missing on display ":3.0"..."
karsten_soit sees a problem relating to JCombobox and autocompletion: "Hi! I upgraded SwingX from 2008_06_08 to current (2009_12_27) and stumbled over following: i use a JComboBox that is decorated by the AutoCompleteDecorator. When calling setText(String text) on the editor-component with a null-value..."
kerbo continues the discussion Re: Migrate SSL App from Apache to GlassFish v3: "Thanks for the information but I am still confused on the correct setup. 1. Using openssl, I created the p12 file from my .crt and .key files. I imported the p12 into the keystore,jks file. I set the alias name to 's1as". Is this correct? In..."
Our current Spotlight is the Annual Developer Quiz put together by Janice Heiss: "For this quiz, SDN staff author Janice J. Heiss surveyed past interviews with leading Java developers in search of questions that might challenge, inform, entertain, amuse, and provoke you. The questions aspire to reflect both the intellectual curiosity and spirit of fun to be found in the Java community. We hope you enjoy taking this quiz... Test your knowledge of Java technology and computing..."
Registered users can submit event listings for the java.net Events Page using our events submission form. All submissions go through an editorial review before being posted to the site.
Archives and Subscriptions: This blog is delivered weekdays as the Java Today RSS feed. Also, once this page is no longer featured as the front page of java.net it will be archived along with other past issues in the java.net Archive.