Posted by editor
on December 30, 2009 at 10:35 AM PST
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...
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.
And here's the application itself:
Happy Holidays [click to run]
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
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!
In Java Today , Jeff Friesen documents the inner workings of his JFXStudio Holiday Challenge winning JavaFX application in his latest post, Happy Holidays :
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...
Geertjan Wielenga discovered Wildland Fire Management on the NetBeans Platform :
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...
Christopher Lam describes How to Create a Java EE 6 Application with JSF 2, EJB 3.1, JPA, and NetBeans IDE 6.8 :
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...
In today's Weblogs , Cay Horstmann writes about JSF 2.0 and Tomcat :
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...
John Ferguson Smart presents Automated deployment with Cargo and Maven - a short primer :
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...
Fabrizio Giudici provides Another example of as(...) used for easily extensible APIs :
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"..."
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..."
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..."
Our current java.net Poll asks "What was the most significant Java/JVM news/event in 2009?" Voting will run through Thursday or Friday (depending on where you live).
We have a new java.net Feature Article by JFXStudio Holiday Challenge winner Jeff Friesen, Reading Newsfeeds in JavaFX with FeedRead , in which Jeff demonstrates how to apply JavaFX's RSS and Atom newsfeed capabilities to create a snazzy little JavaFX app that can run stand-alone or in a browser. We're also still featuring my recent Interview with Java Champion Adam Bien: Java EE 8, Closures, and More .
The latest Java Mobility Podcast is Java Mobile Podcast 92: MIDP 3.0 in Depth: Tutorials and Demonstrations : Excerpts from the JavaOne 2009 MIDP 3.0 In Depth: Tutorials and Demonstrations session with Roger Riggs, Lakshmi Dontamsetti and Stan Kao.
Current and upcoming Java Events :
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 .
-- Kevin Farnham