static void paintCenteredBackgroundImage(Component c, Graphics g, BufferedImage image) { paintCenteredBackgroundImage(c, g, image, c.getBackground()); } static void paintCenteredBackgroundImage(Component c, Graphics g, BufferedImage image, Color backgroundColor) { int w = c.getWidth(); int h = c.getHeight(); g.setColor(backgroundColor); 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); }