Text boxes

Similar to a word processing document, a text box is an object that holds text (a single character, a single word, entire sentences, or paragraphs). Editing in a text box is just like working in a word processor. You can cut, copy and paste selected text easily, and format the text as needed. In addition, a text box can hold other components.

Inserting a text box into a report

A text box can be inserted in the report areas listed in Component placement.

To insert a text box into a report, use either of the following ways:

After a text box has been inserted into a report, you can double-click it to input text. You can also customize its appearance and behavior by setting properties in the Report Inspector, which can be saved as a CSS style for future use (for details, see Creating a CSS style).

Formatting paragraphs in a text box

Paragraphs are created when text is entered into a text box. In JReport, you can easily format the paragraphs, for example, the alignment style, indentation format or line spacing. To do this:

  1. Right-click anywhere in the paragraph and click Paragraph on the shortcut menu.
  2. In the Paragraph tab of the Format Text dialog,
  3. When done, click OK to accept the changes.

You can also set the indentation formats of a paragraph by simply moving the tap stop icons on the ruler. To do this, position the mouse pointer anywhere on the paragraph, then,

Formatting the text in a text box

The text you enter into a text box can be formatted to suit your requirements. For example, you can change the font size, color, alignment, and highlight the text with a distinguishing color. To do this:

  1. Select the text you want to format, right-click and click Font on the shortcut menu.
  2. In the Font tab of the Format Text dialog, specify the font settings.
  3. When done, click OK to accept the changes.

You can also format the selected text by clicking the corresponding buttons on the Format toolbar, or commands of the Text Style submenu on the Format menu.

Finding or replacing a text string

To find a character string in a text box:

  1. Right-click anywhere in the text box and select Find a String from the shortcut menu.
  2. In the Find tab of the Find and Replace dialog, specify the string you want to search for and set the other settings as required.
  3. Click the Find Next button to start finding the specified string.

Similar to finding text, if you want to replace a string in the text box with another one,

  1. Right-click anywhere in the text box and select Replace from the shortcut menu, the Find and Replace dialog will then be displayed with the Replace tab selected.
  2. Specify the settings according to your requirements and click the Replace or Replace All button to replace the next or all the specified string with another one.

Importing and exporting text

To import text into a text box from an external file (.txt or .rtf):

  1. Position the mouse pointer at the location where you want to insert the imported text, then right-click and select Import External File.
  2. In the Import a File dialog, select the .txt or .rtf file you want to import and click OK.

    The text of the file is inserted in the text box.

To export the text from a text box:

  1. Position the mouse pointer on the text, right-click and select Save to RTF File.
  2. In the Save RTF File dialog, specify the name of the file and click OK.

See an example: The SampleComponents catalog, included with JReport Designer, contains reports that have examples of how each component type could be used in a report. For the text box example, open <install_root>\Demo\Reports\SampleComponents\ForTextBox.cls.