static void paintCenteredBackgroundImage(Component c, Graphics g, BufferedImage image) { int w = c.getWidth(); int h = c.getHeight(); g.setColor(c.getBackground()); g.fillRect(0, 0, w, h); if (image == null) ret; int iw = image.getWidth(), ih = image.getHeight(); g.drawImage(image, (w-iw)/2, (h-ih)/2, c); }