demo

Futureboard, a Flipboard-like Scala Futures demo

I’ll write more about this shortly, but yesterday I created a little video of a demo application I call Futureboard. It’s a Scala/Swing application, but it works like Flipboard in that it updates a number of panels — in this case Java JInternalFrames — simultaneously every time you ask it to update.

The “update” process works by creating Scala futures, one for each internal frame. When you select File>Update, a Future is created for each news source, and then simultaneous calls are made to each news source, and their frames are updated when the data returns. (Remember that Futures are good for one-shot, “handle this relatively slow and potentially long-running computation, and call me back with a result when you’re done” uses.)

Here’s the two-minute demo video:

An Akka Actors Ping-Pong example

Here’s a 30-second “ping-pong” demo using Akka Actors:

The source code

If you want the source code, you can get it from the GitHub link shown at the end of this post. First, here’s a quick description of it.

The code is in two files, PingPong.scala and PingPongPanel.scala.

PingPong.scala contains three actors:

Java - get the number of mouse buttons

Java mouse buttons FAQ: How do I determine the number of mouse buttons in a Java application?

I'm working on a Java Swing application, and I'd like to be able to determine the number of mouse buttons on the current system (Mac, Linux, Windows).

The Ruby ternary operator syntax

Here's a quick example of some Ruby source code, showing how I used Ruby's ternary operator in a method that prints a CSV record for a class I defined:

How to use the Perl ternary operator

In most languages there is an operator named the "ternary" operator that lets you write concise if/then statements. This makes for less verbose, which is generally a good thing. Perl also has a ternary operator, and I'll demonstrate it here.

General syntax of the ternary operator

The general syntax for Perl's ternary operator looks like this:

test-expression ? if-true-expression : if-false-expression

Let's take a look at a brief example to demonstrate this.

When a Java method call requires a Class reference

Today I was working with a class that extended the Spring class NamedParameterJdbcDaoSupport, and when I went to use the getNamedParameterJdbcTemplate().queryForObject() method, the third parameter of the method required a Class reference.

How to set the default input focus on a field in an HTML web form alvin May 20, 2008 - 8:53am

When I create a web-based user interface I tend to be a fanatic about making sure that the first input field on a form gets input focus when the form is first displayed. It always drives me crazy when I go to a web form that requires text input, but the developer of the page hasn't taken the time to put the default focus in the first field of the form.

So ... after looking around at some HTML/JSF/Struts/JSP code I've written over the last few years, the following JSF example shows the most concise way I know of setting default input focus on an HTML form field:

Mon, Aug 7, 2006 (Create a curtain behind your application)

I recently created something that I think is a new user interface feature. (What's the saying ... if you haven't seen it before it's new to you(?).) I call it a "curtain", as it is essentially a visual curtain between the window of the application you're working in and the rest of your desktop. You can check it out at this URL.