Extreme Component

JDataGrid Programmer Guide > PrintFactory

PrintFactory - Support JTable printing

PrintFactory creates printable for JDataGrid or JTable. You can print the JDataGrid or JTable by using the PrintFactory.

Print Properties

There are many properties for controling the print page.
NameType
PrintFactory.MARGINjava.awt.Insets
PrintFactory.ORIENTATION
  • SwingConstants.HORIZONTAL
  • SwingConstants.VERTICAL
PrintFactory.HORIZONTAL_ALIGNMENT
  • SwingConstants.LEFT
  • SwingConstants.RIGHT
  • SwingConstants.CENTER
PrintFactory.VERTICAL_ALIGNMENT
  • SwingConstants.CENTER
  • SwingConstants.TOP
  • SwingConstants.BOTTOM
PrintFactory.HEADER_MARGINjava.awt.Insets
PrintFactory.CENTER_MARGINjava.awt.Insets
PrintFactory.FOOTER_MARGINjava.awt.Insets
PrintFactory.HEADER_FONTjava.awt.Font
PrintFactory.FOOTER_FONTjava.awt.Font
PrintFactory.HEADER_FORMATjava.text.MessageFormat
PrintFactory.FOOTER_FORMATjava.text.MessageFormat
PrintFactory.HEADER_ALIGNMENT
  • SwingConstants.LEFT
  • SwingConstants.RIGHT
  • SwingConstants.CENTER
PrintFactory.FOOTER_ALIGNMENT
  • SwingConstants.LEFT
  • SwingConstants.RIGHT
  • SwingConstants.CENTER
PrintFactory.SHOW_HEADER_LINEjava.lang.Boolean
PrintFactory.SHOW_FOOTER_LINEjava.lang.Boolean
PrintFactory.TABLE_SHOW_ROW_HEADERjava.lang.Boolean
PrintFactory.TABLE_SHOW_COLUMN_HEADERjava.lang.Boolean
PrintFactory.TABLE_SHOW_GRID_LINEjava.lang.Boolean
PrintFactory.TABLE_PRINT_AREAcom.zfqjava.swing.cell.Cell

JDataGrid Printable

Code Samples:

// create printable for JDataGrid
// set the print properties
Map map = new HashMap();
map.put(PrintFactory.HORIZONTAL_ALIGNMENT, new Integer(SwingConstants.CENTER));
// map.put(PrintFactory.ORIENTATION, new Integer(SwingConstants.VERTICAL));
map.put(PrintFactory.CENTER_MARGIN, new Insets(6, 0, 6, 0));	
map.put(PrintFactory.HEADER_FORMAT, new MessageFormat(getTitle()));
map.put(PrintFactory.HEADER_MARGIN, new Insets(0, 0, 6, 0));
map.put(PrintFactory.HEADER_ALIGNMENT, new Integer(SwingConstants.CENTER));	
map.put(PrintFactory.FOOTER_FORMAT, new MessageFormat("Page {0}"));
map.put(PrintFactory.FOOTER_MARGIN, new Insets(6, 0, 0, 0));
map.put(PrintFactory.FOOTER_ALIGNMENT, new Integer(SwingConstants.RIGHT));
map.put(PrintFactory.SHOW_HEADER_LINE, Boolean.TRUE);
map.put(PrintFactory.SHOW_FOOTER_LINE, Boolean.TRUE);	
// map.put(PrintFactory.TABLE_SHOW_ROW_HEADER, Boolean.FALSE);
// map.put(PrintFactory.TABLE_SHOW_COLUMN_HEADER, Boolean.FALSE);
// map.put(PrintFactory.TABLE_SHOW_GRID_LINE, Boolean.FALSE);
map.put(PrintFactory.TABLE_PRINT_AREA, dataGrid.getSelectedCell());
// use the PrintFactory to create printable
JDataGrid dataGrid = createDataGrid();
Printable printable = PrintFactory.createPrintable(dataGrid, map);


Copyright (c) zfqjava.com
All rights reserved.