
424
|
Chapter 11, Native Integration and Packaging
#84 Construct Single-Launch Applications
HACK
String track_name = track.name( );
String album_name = track.album( );
String artist_name = track.artist( );
com4j is a great open source project that unleashes the power of Java code
integrated with native applications. The iTunes COM interface provides
hooks for virtually everything that iTunes can do. These two things mean
you could write a program to sort songs, create new playlists, or even export
track listings to your own application that prints CD labels. You can find
fscom/sdk/itunescomsdk.html, so see what other cool things you can come up
with.
H A C K
#84
Construct Single-Launch Applications Hack #84
Only allow one instance of a program, notifying the existing instance when
the user tries to launch a new one.
Most graphical desktop applications are designed for multitasking. You start
your program to work on something, then switch to another program and
come back later. Oftentimes you’ll leave a large program, like a word pro-
cessor, running in the background to be used again when you need to open
another document, say an email attachment you received. When you click
on the attachment, your operating system won’t start a new instance of the
word processor; instead, it will send a message to the currently running
instance to open the new file—saving lots of system resources.
Java programs aren’t