FileDocCategorySizeDatePackage
ComponentPrintable.javaAPI DocExample1096Mon Apr 05 11:55:20 BST 1999None

ComponentPrintable

public class ComponentPrintable extends Object implements Printable

Fields Summary
private Component
mComponent
Constructors Summary
public ComponentPrintable(Component c)

    mComponent = c;
  
Methods Summary
private booleandisableDoubleBuffering(java.awt.Component c)

    if (c instanceof JComponent == false) return false;
    JComponent jc = (JComponent)c;
    boolean wasBuffered = jc.isDoubleBuffered();
    jc.setDoubleBuffered(false);
    return wasBuffered;
  
public intprint(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)

    if (pageIndex > 0) return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    boolean wasBuffered = disableDoubleBuffering(mComponent);
    mComponent.paint(g2);
    restoreDoubleBuffering(mComponent, wasBuffered);
    return PAGE_EXISTS;
  
private voidrestoreDoubleBuffering(java.awt.Component c, boolean wasBuffered)

    if (c instanceof JComponent)
      ((JComponent)c).setDoubleBuffered(wasBuffered);