InteractivePanel extends DrawablePanel implements Printable { public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex > 0) { return Printable.NO_SUCH_PAGE; } Graphics2D graphics = (Graphics2D) g; AffineTransform txOld = graphics.getTransform(); graphics.scale(MM_PER_PX, MM_PER_PX); Rectangle2D boundsOld = getDrawable().getBounds(); Rectangle2D pageBounds = new Rectangle2D.Double( pageFormat.getImageableX()/MM_PER_PX, pageFormat.getImageableY()/MM_PER_PX, pageFormat.getImageableWidth()/MM_PER_PX, pageFormat.getImageableHeight()/MM_PER_PX ); getDrawable().setBounds(pageBounds); try { getDrawable().draw(new DrawingContext(graphics)); } finally { getDrawable().setBounds(boundsOld); } graphics.setTransform(txOld); return Printable.PAGE_EXISTS; } @SuppressWarnings("serial")  InteractivePanel(Drawable drawable); boolean isPopupMenuEnabled(); void setPopupMenuEnabled(boolean popupMenuEnabled); int print(Graphics g, PageFormat pageFormat, int pageIndex); boolean isZoomable(); void setZoomable(boolean zoomable); boolean isPannable(); void setPannable(boolean pannable);  }
@Test public void testPrint() throws PrinterException { BufferedImage image; PageFormat page = new PageFormat(); int ret; image = createTestImage(); ret = panel.print(image.getGraphics(), page, 0); assertEquals(Printable.PAGE_EXISTS, ret); assertNotEmpty(image); image = createTestImage(); ret = panel.print(image.getGraphics(), page, 1); assertEquals(Printable.NO_SUCH_PAGE, ret); try { assertNotEmpty(image); fail(); } catch (AssertionError e) { } }