code: public static void tileImage (Graphics2D gfx, Mirage image, int x, int y, int width, int height)
      {
          int iwidth = image.getWidth(), iheight = image.getHeight();
          int xnum = width / iwidth, xplus = width % iwidth;
          int ynum = height / iheight, yplus = height % iheight;
          Shape oclip = gfx.getClip();
  
          for (int ii=0; ii < ynum; ii++) {
              // draw the full copies of the image across
              int xx = x;
              for (int jj=0; jj < xnum; jj++) {
                  image.paint(gfx, xx, y);
                  xx += iwidth;
              }
  
              if (xplus > 0) {
                  gfx.clipRect(xx, y, xplus, iheight);
                  image.paint(gfx, xx, y);
                  gfx.setClip(oclip);
              }
  
              y += iheight;
          }
  
          if (yplus > 0) {
              int xx = x;
              for (int jj=0; jj < xnum; jj++) {
                  gfx.clipRect(xx, y, iwidth, yplus);
                  image.paint(gfx, xx, y);
                  gfx.setClip(oclip);
                  xx += iwidth;
              }
  
              if (xplus > 0) {
                  gfx.clipRect(xx, y, xplus, yplus);
                  image.paint(gfx, xx, y);
                  gfx.setClip(oclip);
              }
          }
      }
docs: Paints multiple copies of the supplied image using the supplied graphics context such that
  the requested area is filled with the image.