public class RecordDataTableAutoPrinter {
/**
* abgeleitet von JTable
*/
private PrintableRecordDataTable m_PrintableRecordDataTable = null;
/**
* abgeleitet von TableModel
*/
private RecordDataTableModel m_TableModel = null;
private void printRecordDataTable() {
//set preferred orientation
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(m_PrintStartListener.getPreferredOrientation());
/* Fetch printing properties from the GUI components */
MessageFormat header = null;
/* if we should print a header */
/* create a MessageFormat around the header text */
int machineId = 1234;
header = new MessageFormat("Machine ID: " + machineId);
MessageFormat footer = null;
footer = new MessageFormat("- {0} -");
boolean fitWidth = false;
boolean showPrintDialog = false;
boolean interactive = true;
/* determine the print mode */
JTable.PrintMode mode = fitWidth ? JTable.PrintMode.FIT_WIDTH
: JTable.PrintMode.NORMAL;
try {
/* print the table */
boolean complete = m_PrintableRecordDataTable.print(mode, header, footer,
showPrintDialog, set,
interactive, null);
/* if printing completes */
if (complete) {
printApplicationInfo("DONE PRINTING");
} else {
printApplicationInfo("PRINTING CANCELLED");
}
} catch (PrinterException pe) {
printApplicationInfo("EXC: " + pe.toString());
}
}
...
}