| J2TablePrinter 1.2
Sample Code |
J2TablePrinter comes with two sample programs including source code.
The source code for these applications may be freely used, modified, incorporated,
and distributed without restriction as part of any software that uses J2TablePrinter
itself (see License Information).
J2TablePrinterSimpleTest
J2TablePrinterSimpleTest is a small Java application representing the
simplest complete Java program that prints using J2TablePrinter.
It will display a JTable used as a simple spreadsheet containing some typical
tabular data (which you can edit). You can then click on the "Print"
button which will bring up the standard print dialog. Just select
your printer, and hit OK. The source code for the
J2TablePrinterSimpleTest.java is provided with this distribution.
See below for instructions on how to install and run J2TablePrinterSimpleTest.
J2TablePrinterTestApplication
J2TablePrinterTestApplication is a more substantial Java application that will display and print a JTable containing standard file directory information for a folder of your choosing.
The program begins by asking you to select the desired folder (this may be changed by hitting the "New Directory" button at the top). The JTable will then display for all the items in this folder the following information: name, length, modification date, whether it is a directory, whether it is read-enabled, whether it is write-enabled, whether it is hidden, and its full path name.
You may then click on the following buttons:
The source code for J2TablePrinterTestApplication.java and J2TablePrinterPageSetupDialog.java are provided with this distribution. See below for instructions on how to install and run J2TablePrinterTestApplication.
J2TablePrinterTestApplication also includes working code (commented out) for creating a second JTable and second "Pageable" J2TablePrinter instance, then creating a Book containing both documents, and finally printing any of these using the first JTable's J2TablePrinter instance. This demonstrates some of the more advanced capabilities of J2TablePrinter, including making Pageables out of JTable instances, intermixing these Pageables (potentially with your own or ones from other printing components such as J2TextPrinter from Wildcrest Associates) into Books, and printing any of these using either the J2TablePrinter print mechanism or your own.
J2TablePrinterTestApplication also includes code (commented out) for displaying .gif images and/or JCheckBox instances in the boolean-valued JTable columns. The .gif images print fine but slow down printing substantially due to problems in the underlying JDK 1.2.2 system (much improved in JDK 1.3). Likewise, a bug in JDK 1.2.2 prevents JCheckBox's from printing correctly, but it works in JDK 1.3. For further discussion of these problems, see Known Problems in the Installation & Compatibility section.
J2TablePrinterTestApplication also includes code (commented out) for
displaying and printing variable height rows, a feature that is only supported
starting with JDK 1.3. There are numerous other code snippets in
the source code for exercising the many J2TablePrinter features.
Installation
Because J2TablePrinter and both sample applications are Java 2 programs, you must have Java 2 (either JDK 1.2 or 1.3) installed on your system. JDK 1.3 is highly recommended, as you may encounter performance problems, feature limitations, and possible malfunctions when printing under JDK 1.2 (see Installation & Compatibility section). Information is available at the Sun Java site for how to download (free) and install the latest release of Java.
Then, download the file J2TablePrinter120free.zip (or J2TablePrinter120product.zip
if you have purchased J2TablePrinter) and unzip. This will create a J2TablePrinter
folder containing the J2TablePrinter code and documentation along with
the sample applications.
How to run J2TablePrinterSimpleTest and J2TablePrinterTestApplication
1) On Windows systems, go to the J2TablePrinter folder and
double-click one of the following batch files to run the corresponding
program:
runJ2TablePrinterSimpleTest.bat
runJ2TablePrinterTestApplication.bat
2) Alternatively, you can open a command window (shell window in Unix
or MS-DOS window in Windows) and change directory ("cd") to the J2TablePrinter
installation folder and type the desired one of these lines:
java -classpath J2TablePrinterSimpleTest
J2TablePrinterSimpleTest
java -classpath J2TablePrinterTestApplication
J2TablePrinterTestApplication
or on some systems you may need to use these variants:
java -classpath J2TablePrinterSimpleTest;%classpath%
J2TablePrinterSimpleTest
java -classpath J2TablePrinterTestApplication;%classpath%
J2TablePrinterTestApplication
NOTE: On Unix systems, the class path file separator
is generally colon instead of semi-colon, and the class path is designated
by $CLASSPATH instead of %classpath%