Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

8.5 TextPicture

The TextPicture class allows strings to be inserted into a pictorial template. This class separates the specification of the position and width of a field from the formatting of text within the field. TextPicture objects allow you to place fields in text in a visually intuitive manner.

In its simplest form, the TextPicture class can be used like the C language printf() function. In keeping with Java's String-centered I/O, TextPicture allows you to substitute values into a line of text:

An alternative way to write the same thing is:

For this simple example there is no clear advantage over Java's String concatenation:

For more complicated formatting, however, String concatenation can become difficult to read. In complex cases, a separation of the constant from the variable improves readability. Compare this code:

With this code:

In addition, TextPicture allows you to specify field widths pictorially.

This would produce a text table like this:


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.