Unit Testing


To test the Printing application:

  1. Download the Javacomm20-win32 JCA, which is available in zip format. This JCA is available at the following URL:

    http://java.sun.com/products/javacomm/downloads/index.html

  2. Unzip the zip file downloaded from the above URL.

  3. Copy win32com.dll from the unzipped file to the jre\bin directory where Java 2 Software Development Kit (J2SDK) is installed.

  4. Copy comm.jar from the unzipped file to the jre\lib\ext directory where J2SDK is installed.

  5. Copy javax.comm.properties from the unzipped file to the jre\lib directory where J2SDK is installed.

  6. Set the path of the bin directory of J2SDK by executing the following command at the command prompt:

     set path=%path%;D:\j2sdk1.4.0_02\bin; 
  7. Set the classpath of the lib directory of J2SDK by executing the following command at the command prompt:

     set classpath = %classpath%;d:\j2sdk1.4.0_02\lib; d:\j2sdk1.4.0_02\jre\lib\ext\comm.jar; 

  8. Copy the CommPrinting.java, PortChoice.java, FontChoose.java, ColorChoose.java, and Printcomponent_Class.java files to a folder on your computer. At the command prompt, use the cd command to move to the folder where you have copied the Java files. Compile the files using the javac command, as follows:

     javac *.java 
  9. Run the Printing application using the following command at the command prompt:

     java CommPrinting 
  10. Select File->Open to open the text document that you want to print. The selected document opens in the user interface, as shown in Figure 4-8:

    click to expand: this figure shows the text document that the end user needs to print using the printing application.
    Figure 4-8: The Printing Application Interface

  11. Click File->Choose COM Port to Print to select the port to which the printer is connected. You can select the port to use for printing from the list of ports that appears on the user interface of PortChoice.java and click OK.

  12. Select Font->Font to set the font of the text in the document to be printed. The Selecting the Font dialog box appears.

  13. Select the type, style, and size of the font of the text in the document and click OK. The font of the text changes to the selected font, as shown in Figure 4-9:

    click to expand: this figure shows the font of the text changed to verdana, the font size changed to 10, and the font type changed to bold and italics.
    Figure 4-9: Changing the Font

  14. Select Color->Color to select the color of the text in the document to be printed. The Selecting the Color dialog box opens. The end user can select a specific color for the text and click OK. This changes the color of the text in the document to the selected color, as shown in Figure 4-10:

    click to expand: this figure shows that the color of the text has changed to sky blue.
    Figure 4-10: Changing the Color

  15. Select File->Page Setup and Print to print the text in the document that is currently opened. This opens the Page setup dialog box, as shown in Figure 4-11:

    click to expand: this figure shows the page setup dialog box to set the paper size and the orientation of the page to be printed.
    Figure 4-11: The Page Setup Dialog Box

  16. Click OK. The Print dialog box opens, as shown in Figure 4-12:

    click to expand: this figure shows the print dialog box where the end user can set the page numbers and the number of copies to be printed.
    Figure 4-12: The Print Dialog Box

  17. Click OK.




Developing Applications Using JCA
Developing Applications Using JCA
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 43

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net