Displaying status information

Many data applications provide status information about the data in addition to displaying the data itself. For example, a particular area of a window often contains information on the current row position, error messages, and other similar information. The JBCL includes a StatusBar control which provides a mechanism for such status information. It has a text property that allows you to assign a text string to be displayed in the StatusBar. This string overwrites the existing contents of the StatusBar and is overwritten itself when the next string is written to the StatusBar.

You can also connect the StatusBar control to a DataSet. The StatusBar control doesn't display the data from the DataSet but displays the following status information generated by the DataSet:

Building an application with a StatusBar control

This section serves both as general step-by-step instructions for your real-world application, and as a tutorial with sample code and data.

You can add a StatusBar control to your application in two ways:

Running the StatusBar application

When you run the application, you'll notice that when you navigate the data set, the row indicator updates to reflect the current row position. Similarly, as you add or delete rows of data, the row count is updated simultaneously as well.

To test its display of validation information:

  1. Insert a new row of data. Attempt to post this row without having entered a value for the FIRST_NAME or LAST_NAME columns. A message displays in the StatusBar indicating that the row cannot be posted due to invalid or missing field values.

  2. Enter a value for the FIRST_NAME and LAST_NAME columns. Enter a number in the SALARY column that doesn't meet the minimum value. When you attempt to move off the row, the StatusBar displays the same message that the row cannot be posted due to invalid or missing field values.

By setting the text of the StatusBar at relevant points in your program programmatically, you can overwrite the current message displayed in the StatusBar with your specified text. This text message, in turn, gets overwritten when the next text is set or when the next DataSet status message is generated. The status message can result from a navigation through the data in the grid, validation errors when editing data, and so on.

For other examples of applications that include a StatusBar control, see the following topics: