static JPanel jTiledBackground(S imageID, Component contents) { final BufferedImage tileImage = loadImage2(imageID); JPanel panel = new JPanel(new BorderLayout) { protected void paintComponent(Graphics g) { int width = getWidth(); int height = getHeight(); for (int x = 0; x < width; x += tileImage.getWidth()) for (int y = 0; y < height; y += tileImage.getHeight()) g.drawImage(tileImage, x, y, this); } }; panel.add(BorderLayout.CENTER, contents); ret panel; }