| TextPrinter 1.0
User Manual |
![]() |
WILDCREST ASSOCIATES |
After TextPrinter.jar
is properly installed, you will see the TextPrinter bean in the component
palette of your visual programming environment. Click on the TextPrinter
bean and drop it on your work area. You will see a TextPrinter printer
icon representing the bean.
When you bring up the property sheet for TextPrinter (right), you will be able to see and edit all the property values supported by TextPrinter. Clicking on the "Text" field brings up a separate scrolling text area property editor, into which you can type or paste text to be printed. The text is one long string representing the entire text document to be printed. It may have hard line separators typed in explicitly by you. Or you can rely on TextPrinter's automatic line wrapping feature to break long lines. The rest of the properties may be set as desired, with values as defined in the TextPrinter Javadoc documentation.
You can make the TextPrinter bean print by using your visual programming environment to perform event wiring from an actionPerformed event such as a button push to the TextPrinter "print" event target method. TextPrinter also exposes all the regular inherited component methods such as show, hide, enable, disable, etc.
TextPrinter is a subclass of Canvas. It overrides "paint" for purposes of displaying the printer icon during composition in your visual programming environment. The "paint" and "print" methods are the only methods that TextPrinter overrides.
All the TextPrinter properties are bound properties. You may use your visual programming environment to do property-to-property binding in either direction between TextPrinter and your other beans. None of the TextPrinter properties are constrained properties. This frees you from having to place try...catch blocks around set calls in regular programming.
TextPrinter is fully serializable. After customizing any of its
properties (including the text), an instance of TextPrinter can be
saved along with any other beans to which it may be wired. When reloaded,
the TextPrinter bean will come back with its customized values. No
TextPrinter properties are declared transient.
Using TextPrinter as a class
TextPrinter may also be used programmatically as a simple class. TextPrinter is distributed in the package com.wildcrest. A com folder with a wildcrest subfolder containing TextPrinter.class should be placed somewhere in your classpath (see Installation instructions).
You may find it useful to begin your program with:
import com.wildcrest.TextPrinter;
or you may make calls to TextPrinter with the full package name:
com.wildcrest.TextPrinter();
TextPrinter is instantiated with a zero-argument constructor:
TextPrinter printer = new TextPrinter()
Or, more typically, you set the desired string to be printed using:
printer.setText(stringToPrint)
and follow with a call to the zero argument print method:
printer.print()
That's all you need! The following is a very simple but complete Java program that prints:
import com.wildcrest.TextPrinter;
class TextPrinterTest {
static public void main(String
args[]){
TextPrinter printer = new TextPrinter();
printer.print("String that will be printed");
}
}
Most of the methods of TextPrinter are set and get methods for controlling
its property values. The defaults for all these values are shown in the
property list editor in the "Using TextPrinter as a JavaBean" section above.
The full list of TextPrinter constructors and methods, what they do, and
their default values are given in the TextPrinter
Javadoc documentation.