Coding Cognitions
  thoughts on binary expression

JavaFX Coding Challenge

by John Bohlmann | 10:35 PM in , , | comments (0)

I recently attended a MySQL tech talk at Purdue hosted by Sun, and the speaker announced a Sun contest for developing JavaFX applications. It has prizes up to $25k, including exclusive prizes for students, which is great for our student team. Thus, we are going to be competing in the JavaFX Coding Challenge with our project! We've also officially named the project Toru, which means "to take" or "to harvest" (knowledge) in Japanese, and is symbolic of the project's purpose.

Toru is a community-centric information service, similar to Yahoo! Answers or ChaCha, with distinctive improvements in mobility (via JavaFX) and community features (such as competitions and more score-based answering). We are aiming for it to be an application which is more open and accessible than ChaCha but with more answer reliability than Yahoo! Answers. Initially we're deploying for use home computers, but soon after we'll add support for mobile devices and even new TVs with web access technology. Toru is going to have a "question lobby" for users who are interesting in answering questions, and this will strengthen the answers provided to be more like ChaCha's. We'd also like to add some cool competitive features such as periodic "sprint" contests with bonus points for answering questions, and possibly prizes!

The Coding Challenge looks to be a great opportunity to demo Toru and gain a lot of nice experience with JavaFX! The submission deadline is May 29th, so we'll need to go through a crash course in JavaFX specifics. ;) In addition to the great prizes, the contest would be sure to generate a bunch of publicity for your application. We're looking forward to competing!

Data binding is one of the most important JavaFX features you should learn when creating web applications. It's also one of the easiest to get confused about. In this post, I will cover tips on using the bind keyword, and mention a few ways we're using data binding in our project.

Basically, bind is a mechanism for ensuring a variable is always up-to-date when rendered or used by your functions. For example, if we had a Text component which we wanted to update with new messages from a global data service, we can declare the content property to be bound to the service as follows:

var boundText: Text = Text{
x: 10
y: 10
content: bind asyncService.currentText
}
Note that a bind must be declared at compile time, and once a variable is bound to something, you cannot access it directly.

Another useful feature is the on replace keyword, which lets you define a function delegate to be executed whenever a certain variable is changed.
public var replaceText: String = "Hello world!" on replace oldText{
println("Text has been replaced");
};
I prefer to use on replace as opposed to bind when I can, as it seems to run a bit faster for our project. This is likely because it only edits the variable with an on replace, whereas with a bound variable, every time the data source is updated a new objects is created and reassigned to the variable. And although you can bind to expressions, on replace allows a full-blown function call.

Both bind and on replace are extremely useful and essential tools when developing in JavaFX. In our project, we use them primarily for tieing the GUI to our data, and for supporting callbacks from our business logic code to the GUI. To learn more about them, you can go to the official website for tutorials on these and other JavaFX features. Enjoy!

A New Journey: JavaFX

by John Bohlmann | 9:29 PM in , , | comments (0)

Over the past month a friend and I have been working on a project using Sun's new cross-platform Rich Internet Application framework, JavaFX. So far it's been an interesting experience, involving both ups and downs, but overall very exciting and useful. In this blog I plan to chronicle notable points in our development process, and hopefully include lots of helpful information for those wanting to jump on this cutting-edge framework.

About me

John Bohlmann is a computer scientist at Purdue University. He enjoys experimenting with computer graphics, human/ computer interfaces, and future web platforms.