ImageData imageData = image.getImageData(); imageData.transparentPixel = imageData.palette.getPixel(background.getRGB()); image.dispose(); image = new Image(display, imageData);
  private Image getStateImage(Color background, String state) {    Image image = (Image) imageHash.get(state);    if (image == null)     {      System.out.println("Creating image " + state);      ImageData stateImageData = basicSkinable.getImageData(state);      if (stateImageData != null) {        ImageData mergedImageData = imageMerger.merge(background, stateImageData);        image = new Image(display, mergedImageData);      }      else {        final int width = 80;        final int height = 20;        image = new Image(display, width, height);             GC gc = new GC(image);        if (state.startsWith("%")) {          int percent = Integer.parseInt(state.substring(1));          int barY = height / 4;          int barHeight = height / 2;          gc.drawRectangle(0, barY, width - 1, barHeight - 1);          gc.setBackground(gc.getForeground());          gc.fillRectangle(0, barY, width * percent / 100 - 1, barHeight - 1);        }        else {          /* We need to generate an image for the text */          Point size = gc.stringExtent(state);          if (size.x > width) {            // Shrink to fit! The downloading messages            // are too big on Mac OS X at least.            FontData fd = gc.getFont().getFontData()[0];            Font font = new Font(display, fd.getName(), fd.getHeight() * width / size.x, fd.getStyle());            gc.setFont(font);            size = gc.stringExtent(state);          }          gc.drawText(state, (width - size.x) / 2, (height - size.y) / 2, true);        }        gc.dispose();      }      imageHash.put(state, image);    }    return image;  }