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