docs: public int print(Graphics g, PageFormat pageFormat, int pageIndex) 
      {
          Graphics2D g2d = (Graphics2D)g;
  
          if (firstTime)
          {
              m_componentPrint = new ComponentPrint(null);
              m_componentPrint.surveyComponents(m_component);
              m_paperPrint = new PaperPrint(null);
              m_paperPrint.surveyPage(pageFormat, g2d, m_bPrintHeader);
              firstTime = false;
          }
  
          // Print this page
          int pageHeight = m_paperPrint.getPrintableHeight();
          double scale = Math.min(1.0, ((double)m_paperPrint.getPrintableWidth() / (double)m_componentPrint.getMaxComponentWidth()));
  
          m_paperPrint.setCurrentYLocation(0);
          m_componentPrint.setPageHeight((int)(pageHeight / scale));
          boolean pageDone = m_componentPrint.setCurrentYLocation(pageIndex, 0);
          
          while (!pageDone)
          {
              Component component = m_componentPrint.getCurrentComponent();
              int componentCurrentYLocation = m_componentPrint.getCurrentYLocation();
              int componentHeightOnPage = m_componentPrint.getComponentPageHeight();
  
              if (this.isCancelled())
                  return NO_SUCH_PAGE;    // Done, No more pages
              if (component == null)
              {
                  if (m_paperPrint.getCurrentYLocation() == 0)
                      return NO_SUCH_PAGE;    // No more pages
                  else
                      break;  // End of components (last page)
              }
  
              if (m_paperPrint.getCurrentYLocation() == 0)
              {       // First time through
                  if (m_bPrintHeader)
                  {
                      m_paperPrint.printHeader(g2d, m_componentPrint.getTitle());
                      m_paperPrint.printFooter(g2d, "Page " + (pageIndex + 1));
                  }
                  this.setDialogMessage("Printing page " + (pageIndex + 1));
              }
  
              int xShift = m_paperPrint.getXOffset();
              int yShift = m_paperPrint.getYOffset() - (int)(componentCurrentYLocation * scale);
  
              g2d.setClip(m_paperPrint.getXOffset(), m_paperPrint.getYOffset(), m_paperPrint.getPrintableWidth(), (int)(componentHeightOnPage * scale));
              g2d.translate(xShift, yShift);
              g2d.scale(scale, scale);
              disableDoubleBuffering(component);
              component.paint(g2d);
              enableDoubleBuffering(component);
              g2d.scale(1 / scale, 1 / scale);
              g2d.translate(-xShift, -yShift);
  
              m_paperPrint.addCurrentYLocation((int)(componentHeightOnPage * scale));
              pageDone = m_componentPrint.addCurrentYLocation(componentHeightOnPage);
          }
          return PAGE_EXISTS;
      }