A statusbar is a widget that usually is displayed along the bottom of the main application window and is used to display helpful text messages to the user. The GTK implementation of a statusbar works like a FIFO queue. Messages are "pushed" on the statusbar and are "popped" off the statusbar. In GNOME we have the added benefit of being able to connect the statusbar to the UIInfo hints associated with menu items. Let's extend the example and add a statusbar to see how this works. We will only show the updated code in the following listing.
Example 4-2. Third.java - second take
public class Third { private GnomeApp app = null; private GtkStatusbar statusbar = null; public static final String appVersion = "0.1"; public Third() { createMainWindow(); createMenusAndStatusbar(); createToolbar(); app.showAll(); } ... private void createMenusAndStatusbar() { ... app.createMenus(mainMenu); statusbar = new StatusBar(); app.setStatusBar(statusbar); app.installMenuHints(mainMenu); } ... }
In this updated example we have renamed our createMenus() method to createMenusAndStatusbar(). At the end of this method we create a Statusbar object, add it to the App with a call to setStatusBar() and install the menu's hints with a call to installMenuHints(). When you move your mouse over any menu item you will see it's hints displayed in the statusbar.
So far we have put together a shell that contains a menu, a toolbar and a statusbar. Now it is time to move on to adding widgets to our application. But first we must understand the concept of layout managers, which is the topic of the next chapter.