Open source Java projects: Balloontip for Java

Add balloon tips to your Swing GUIs

You can save time and reduce other costs associated with Java development by taking advantage of open source Java projects. In this new series, Jeff Friesen introduces a variety of lesser known open source Java projects that can benefit your Java software. Jeff begins the series by looking at Bernhard Pauler's balloontip project, which you can use to add Windows XP-style informational "balloons" to your Swing-based Java applications.

Open source licenses
Open source software is usually subject to some form of license, which determines how the software can be used. The balloontip project is released under the GNU Lesser General Public License (LGPL). See this article's Resources section to learn more about the LGPL.

A balloon tip is a small window that presents an informational message to remind or otherwise notify application users of significant events. Its name is derived from the fact that balloon tips have a similar appearance to the speech balloons found in comic strips.

Windows XP supports balloon tips in the context of its taskbar notification area and this area's icons. You can see this in Figure 1, where XP displays a balloon tip above and partly over a notification area icon after something significant has happened.

The balloon tip in Figure 1 is positioned in such a way as to identify its associated notification area icon. The figure also reveals a Close button to close the balloon tip window, and a small "i" icon, which classifies the balloon tip as informational.

A balloon tip identifies a new high-speed Internet connection.
Figure 1. This balloon tip identifies a new high-speed Internet connection

Bernhard Pauler's open source balloontip project introduces XP-like balloon tips to Swing GUIs. In this first article in the new "Open source Java projects" series, I'll show you how to obtain and install the balloontip software. I'll also walk you through balloontip's example application, explore the balloontip API, and explain where balloon tips are useful in Swing-based Java development.

Obtain and install balloontip

The balloontip project's Balloon Tips for Java page, hosted on Java.net,

A shorter path home
On my XP platform, C:\unzipped\BalloonTip_2007-05-15\BalloonTip was the initial path to the BalloonTip home directory. Because I like to work at the command line, I found it tedious to navigate this path. To remedy this situation, I moved the home directory to my C:\jp (Java Projects) directory, resulting in C:\jp\BalloonTip as a simpler path. If you also like to work at the command line, you might want to do something similar on your platform.

introduces balloontip. Among other things, you'll find a link to the latest version of the software on this page.

At the time of writing this article, the latest version available is BalloonTip_2007-05-15.zip. After downloading and unzipping this archive, I discovered a BalloonTip_2007-05-15 directory containing BalloonTip as the home directory.

The BalloonTip home directory contains classes and src subdirectories. It also contains README.txt, which briefly describes how to run the BalloonTipTestDrive example application. The complete directory structure is shown in Listing 1.

Listing 1. Balloontip project directory structure

BalloonTip
  classes
    net
      java
        balloontip
          examples
            BalloonTipTestDrive$1.class
            BalloonTipTestDrive$2.class
            BalloonTipTestDrive$3.class
            BalloonTipTestDrive.class
          images
            closebutton_default.png
            closebutton_pressed.png
            closebutton_rollover.png
            frameicon.png
            infoicon.gif
          utils
            WindowUtils.class
          BalloonTip$1.class
          BalloonTip$2.class
          BalloonTip$3.class
          BalloonTip.class
          EdgedBalloonBorder.class
          RoundedBalloonBorder.class
  src
    net
      java
        balloontip
          examples
            BalloonTipTestDrive.java
          images
            closebutton_default.png
            closebutton_pressed.png
            closebutton_rollover.png
            frameicon.png
            infoicon.gif
          utils
            WindowUtils.java
          BalloonTip.java
          EdgedBalloonBorder.java
          RoundedBalloonBorder.java
  README.txt

The classes hierarchy provides Java SE 6-compiled code for the net.java.balloontip, net.java.balloontip.examples, and net.java.balloontip.utils packages. Only the former package and the three closebutton PNG images constitute the balloontip API.

Make a JAR file
Follow these steps to create a JAR file if you find it more convenient to work with a JAR file than a classes hierarchy of class files:
  1. Make sure that the classes directory is the current directory.
  2. Invoke jar cf balloontip.jar net to create the JAR file.
This command creates a balloontip.jar JAR file containing the entire directory structure located beneath the classes directory.

The src hierarchy provides all source code and a duplicate of the various image files. The source code for the balloontip API consists of BalloonTip.java, EdgedBalloonBorder.java, and RoundedBalloonBorder.java.

After the archive is unzipped (and BalloonTip possibly moved to another location), complete the installation by pointing the CLASSPATH environment variable to the classes directory (unless you create a JAR file that you specify via the java command's -cp option).

Test drive balloon tips

The BalloonTipTestDrive example application demonstrates balloon tips associated with a text field component. You should download it now if you haven't already done so. Once you've downloaded the test drive package, specify java net.java.balloontip.examples.BalloonTipTestDrive to run the program. A GUI like the one shown in Figure 2 appears.

The BalloonTipTestDrive demonstration GUI.
Figure 2. Specify exactly five characters to see the balloon tip
1 2 3 4 Page
Join the discussion
Be the first to comment on this article. Our Commenting Policies
See more