Automatic images doesn't work in JPanel

Hi all!

After reading up on Automatic Images I implemented them in my game (which gave a huge fps boost) and I am now trying to get them to work in my mapeditor which is Swing-based.

I am drawing them in a JPanel but after about 40-50 succesive calls to g.drawImage on my second call to repaint everything just stops running.

If anyone has any idea on what I am doing wrong I have included the code that draws and the part that loads the images. Any general information on anything else that i might be doing wrong is gladly appreciated!

Overriden paint-method in JPanel:


    Image curimg;
    for (int i=0;i<noTiles;i++) {

      xOffset += 32;
      if ( (i % columns) == 0) {
        yOffset+=32;
        xOffset = 0;
      }
      curimg = th.getTile(tilesetName, i);
      g2.drawImage(curimg,xOffset,yOffset,this); // This is where it hangs
    }

Here is the code to load the images:


    util.log("Processing tiles in " + filename);
      //Load main image and wait it to complete loading
      tkImg = Toolkit.getDefaultToolkit().createImage(filename);
      MediaTracker tracker = new MediaTracker(win);

      tracker.addImage(tkImg,0);
      try {
        tracker.waitForAll();
      }
      catch (InterruptedException ex) {
      }

//  --- Some code removed here --- 

// Splits the main image into tiles
    int i=0;
    for (int y=0;y<tilesY;y++) {
      for (int x=0;x<tilesX;x++) {
      tileArray[i] = gc.createCompatibleImage(32,32, Transparency.BITMASK);
      Graphics2D big = (Graphics2D)tileArray[i].getGraphics();
      big.drawImage(tkImg, -32*x, -32*y, null);

      i++;
      }
    }