Sunday Sep 28, 2008
Sunday Sep 28, 2008
I knew my best path to learning JavaFX and creating my countdown timer app would be to study one of the existing sample applications. The stopwatch example seemed perfect, as it contained basic timer logic (though counting up and not down) and had both a digital and clock-style display. First though, I stopped by javafx.com and downloaded the JavaFX Preview SDK so I'd have all the runtime components and NetBeans IDE. I then grabbed the stopwatch example, installed it as a project in NetBeans, and started examining the code.
The file structure of the project helped me get a feel for what I needed to do, though the terminology was unfamiliar. A short main program (Main.fx) created a "Frame" and populated it with a StopwatchWidget. Looking next at StopwatchWidget.fx I saw it created a customized "Node" with a "Model" called StopwatchModel and a "Theme" called LightTheme. StopwatchModel.fx contained all the timer logic and functions to start, stop, and reset the stopwatch. LightTheme.fx contained all the code to render the user interface - stopwatch face, hands, dial markings, start/stop buttons, etc.. It extended an overall "Theme", which I found in Theme.fx, not surprisingly and discovered there was an alternative DarkTheme in DarkTheme.fx.
I wanted to get started by reversing the timing function so the stopwatch counted down and not up, so dug into StopwatchModel.fx. Reversing the rotation of the timer hands was easy enough but that didn't mean I was counting down. However, since JavaFX lets me mix JavaFX Script and Java I could splice in the Java code from my previous countdown timer both to calculate milliseconds remaining until the target date/time and to extract from that values for the days, hours, minutes, and seconds remaining so I could update the digital display. In doing so I learned a few things:
var year:String = "2008";
var now:Integer = System.currentTimeMillis() as Integer;
At this point, though, I had converted my timer logic into JavaFX inside StopwatchModel to produce:
private attribute targetString:String = "2009-03-27-8-0"
private attribute targetMilliseconds:Number = 0;
private attribute timerListener:ActionListener = ActionListener {
public function actionPerformed(evt:ActionEvent): Void {
if (targetMilliseconds == 0) {
var formatter:SimpleDateFormat = new SimpleDateFormat("yyyy-M-d-k-m");
var date:Date = formatter.parse(targetString);
targetMilliseconds = date.getTime();
}
var now:Integer = System.currentTimeMillis() as Integer;
var nn:Number = System.currentTimeMillis() as Number;
var n:Integer = ((targetMilliseconds - nn)/1000) as Integer;
if (n > 0) {
var s:Integer = n mod 60;
var m:Integer = n / 60;
var h:Integer = m / 60;
var d:Integer = h / 24;
h = h mod 24;
m = m mod 60;
timeString = "{%03d d}-{%02d h}:{%02d m}.{%02d s}";
}
else {
timeString = "000-00:00.00";
}
}
}
This gave me the ability to count down properly and set the right value in the magical global timeString, but I clearly couldn't map this to the digital display of the stopwatch much less the moving hands. That meant serious modification to the user interface, which I'll cover in my next blog entry.
Thursday Sep 18, 2008
This past weekend I got started on my personal project to learn programming in JavaFX. While I am a Marketing Guy by day I spent a lot of years as a software engineer and my career is founded far more on C programming than B School. I've explored basic Java plus tinkered with a variety of scripting languages. I figured I'd be a good novice test case for JavaFX Script and its powerful graphics and media capabilities.
Getting started was easy enough as everything you need -- the Preview SDK, sample programs, and API documentation -- is available via javafx.com. The NetBeans IDE makes it easy to create a JavaFX project and begin editing .jx files.
So what to build? Deciding on my first JavaFX app was easy. Just prior to JavaOne this year I used NetBeans to create in Java a countdown timer I could use to remind us all how many (or how few) days remained before the start of JavaOne. Obviously I needed to craft a JavaFX version of that same countdown app to use for this year. (And yes, we are already well into the planning for JavaOne 2009.)
I went from initial download of the JavaFX Preview SDK to completion of the JavaFX countdown timer app in two evenings. It was easy, fun, and I learned quite a lot. NetBeans and a couple of JavaFX sample applications were tremendously valuable, along with the API docs on javafx.com.
A screen snapshot of my completed application is at the top of this blog entry. Over the course of a few more entries I'll talk about the development experience and my observations about JavaFX Script. What I can say for now is that ease with which I built my first application has me convinced that JavaFX will let me do something I couldn't have done before -- create Rich Internet Applications for desktop, mobile, and TV. I can't wait!
Tuesday Sep 16, 2008
The latest episode of our "This Ain't Your Dad's Java" podcast is available with special guest Danny Coward, Chief Client Architect for Java. Our topic is Java SE and the cool new update 10 release of Java SE 6 (so "Java SE 6u10" or just "6u10"). There are a lot of great features in 6u10, with "draggable applets" being one of my favorites. We've had had over a million downloads of the early access so far. (Get it yourself here).
Danny has put together a nice compendium of Java related podcasts in his blog, and I love his summary of "Ain't Your Dad's Java."
Danny has also started a new blog, The Planetarium, as a daily news wire on all things related to client Java from smart cards to mobile devices to desktops. If you only have time each day for one quick check of interesting updates on Java then The Planetarium is the place to look.
Sunday Sep 07, 2008
I'm having a great time as co-host of the "This Ain't Your Dad's Java" podcast we started back in late July. Eric Klein, my boss and the VP of Java Marketing, is host and Jennifer Winger is our producer. Our idea is to have episodes more or less weekly and talk about all things Java. We'll share news of what's going on in the Java product group at Sun, have a special guest to chat with us about a topic of particular interest, and introduce cool new Java products from all corners of the marketplace.
The title of the podcast means more than you might think. The breadth, presence, and scope of Java in the world today is extraordinary - the result of over a dozen years of innovation and inspiration by innumerable contributors at Sun and elsewhere. We could spin up a podcast on just that and be busy for a long time to come.
The big story, though, and what has all of us at Sun so excited, is where we are taking Java. It's about immersive, media rich, highly stylized applications and services that are built collaboratively by developers, designers, scripters, artists and others to take full advantage of the unsurpassed ubiquity of the Java platform and the pervasiveness of the Internet. It's a time of rapid evolution and explosive growth, and while there's an awful lot yet to happen at Sun and elsewhere it's clear that what's emerging "ain't your dad's Java".
We've recorded six episodes so far with topics and guests covering the history of Java (James Gosling), Java gaming (Chris Melissinos our Chief Gaming Officer), Java strategy and futures (Jeet Kaul, VP of Java Engineering), Java in TV and Media (Bill Sheppard our Chief Digital Media officer), and JavaFX (Param Singh, Sr. Director of Mktg for JavaFX). We like to get our guests to reveal a bit about themselves and have had a lot of fun, perhaps to the point of saying things we might oughtn't.
Our podcast is available via the iTunes store and cross platform via Feedburner. You'll find an icon and link in the navbar of my blog. We're hoping to get questions from listeners and answer them on the air, so if you have anything you'd like to know about Java drop us a line at aintyourdadsjava@sun.com
Eric, Jenn and I, on behalf of all our guests past and future, hope you'll give us a listen and let us know what you think.
Saturday Feb 18, 2006
This week I attended the 3GSM World Congress (usually just called "3GSM") in Barcelona, Spain. 3GSM bills itself as "the most important gathering for the mobile industry" and it's pretty hard to argue with that. Most of my time was spent meeting with partners, customers, potential partners, and potential customers, but I did have some time to explore the exhibit halls. That exploration was constrained to be cursory as the exhibits covered four floors in three large and separate buildings and housed several hundred vendors. Even if I had made it a full time job for the three days I was there I could hardly have made a thorough investigation. However, zooming through quickly does offer an opportunity to do some visual integration of what's on display and from that I extracted a few observations to share.
First and foremost, I'd say the Age of Entertainment is upon us thanks to a happy convergence of relatively recent progress on three fronts. Handset manufactures are now producing mobile phones with sufficient multimedia capabiliites and on-board storage that they can run engaging games, receive captivating video streams, and play CD-quality music. Our cellular networks now have the bandwidth to drive that volume of information to devices at a price point that people will find acceptible. And there's enough motivation among game, video, and music creators to begin capitalizing on the opportunity by creating content well suited for delivery and consumption by mobile consumers. Better still, it's a win-win-win-win situation for everyone involved. Device manufacturers offer these features as enticements to trade in last year's cell phone, carriers thrill in the increased consumption of billable connect minutes, content providers have sufficient markets to generate positive return on their creative investment, and humans in general have the ability to be truly and affordably entertained any time, anywhere.
It seems to me the key concept here is "entertainment". It's what binds all these communities together and creates the ecosystem that can sustain them. Yes, there are some other active and interesting markets - one oft-cited example being mobile enterprise applications such as corporate email, group scheduling, and document sharing - but I think the practical maximum demand in that market pales in comparison to entertainment.
3GSM was awash in folks offering to contribute to the entertainment ecosystem. I was pleasantly surprised at the number of new and speculative device manufactures. Little companies were everywhere offering interesting alternatives to the traditional phone vendors, in some cases banding together to form groups around common platforms like Linux. And the established heavy hitters weren't resting on their planet-sized laurels either. Sony Ericsson seems to have become a veritable volcano of devices, erupting new ones almost continuously. Models that premiered last November are now being swept aside by new versions both major and minor, with obvious emphasis on combining phone, digital camera, music player, and TV. I had the pleasure of borrowing a Sony W900i (new at Thanksgiving but now surpassed) for my time at 3GSM. It has a high quality 240x320 display with powerful on-board graphics controller, 2 megapixel camera, built in music player with a separate control panel spliced into the headset cable, 470Mb of storage for music & media, Bluetooth, Java ME support, Memory Stick slot for accessing all your media, and it still fit comfortably in my pocket.
The producer end of the ecosystem was also present in force. Most of them were concentrated in a special "Content Zone", largely because a thriving subsegment is populated by "adult entertainment" and let's just say their booths were not the kind of thing you wanted people to accidentally wander into. Games were everywhere. Serialized content was hot as well, with many companies specializing in animated episodic entertainment built around characters like "Cat Bastard" and "Suicidal Squirrels". (Think of it as if new "Itchy and Scratchy" cartoons were pushed out to your phone every two weeks.). Vendors specialize in helping content creators package their media so as to reach the largest possible range of devices and carriers, and extend thriving mainstream developer tools like NetBeans to serve the mobile market.
Carriers get help too, in the form of products like Sun's Content Delivery Server, which provide powerful platforms for getting all that content out to folks and making possible marketing campaigns that promote new services and reward consumers for purchases or plan upgrades. Carriers are going to need as much of this kind of technology as they can get as we will soon reach the point where success will depend on ulitmate flexibility in creating offers and linking titles at the peak of their bursts of fame so as to drive more consumption.
There came a time in the evolution of the Internet where the matra became "Content is King". For the mobile marketplace I think the mantra is "Entertainment is King".
A few other quick observations in closing: