bookExamples.ch44Printing
Class DYMOLabelPrintConnector

java.lang.Object
  extended by bookExamples.ch44Printing.DYMOLabelPrintConnector
All Implemented Interfaces:
java.awt.print.Printable

public class DYMOLabelPrintConnector
extends java.lang.Object
implements java.awt.print.Printable

Print Labels for DYMO LabelWriter 400

Version:
$Revision$
Author:
 Martin Scholz 

Field Summary
static java.lang.String PRINTERNAME
          name of the printer as known in the settings.
static boolean PRINTMENU
          true if you want a menu to select the printer
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
DYMOLabelPrintConnector()
           
 
Method Summary
 int getPageNumbers()
           
 java.lang.String getValue(int elementOnLabel, int labelCounter)
          overwrite this method in order to get other values.
static void main(java.lang.String[] args)
          GO !
 int print(java.awt.Graphics graphics, java.awt.print.PageFormat pageFormat, int pageIndex)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRINTERNAME

public static final java.lang.String PRINTERNAME
name of the printer as known in the settings. If you dont know the exact name, leave it empty and set PRINTMENU to true - this will activate the menu.

See Also:
Constant Field Values

PRINTMENU

public static final boolean PRINTMENU
true if you want a menu to select the printer

See Also:
Constant Field Values
Constructor Detail

DYMOLabelPrintConnector

public DYMOLabelPrintConnector()
Method Detail

main

public static void main(java.lang.String[] args)
GO !

Parameters:
args - unused

getValue

public java.lang.String getValue(int elementOnLabel,
                                 int labelCounter)
overwrite this method in order to get other values. The current implementation will generate lables with 5 lines.

  1. "SetupX"
  2. "fiehnlab.ucd"
  3. "id" + the current counter number
  4. "label" + the position
  5. the current date

Parameters:
elementOnLabel - position of the field ON the label.
labelCounter - counter of ALL labels - first label is 0
Returns:
the value for the specific field

print

public int print(java.awt.Graphics graphics,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

getPageNumbers

public int getPageNumbers()
Returns:
index of the last page.