Possible Duplicate:
Cannot make a static reference to the non-static method
I am trying to tile a background, but now I am stuck. I have read the documentation for createImage()
, but for some reason something is static, and I can't figure out how or why.
Here is the code I have:
Paint paint;
if (paint == null) {
try {
// Create TexturePaint instance the first time
Component c;
Image image = c.getToolkit().getImage("Background.png");
int height = image.getHeight(null);
int width = image.getWidth(null);
BufferedImage bi = (BufferedImage) Component.createImage(width, height);
Graphics2D biG2d = (Graphics2D) bi.getGraphics();
biG2d.drawImage(image, 0, 0, Color.black, null);
paint = new TexturePaint(bi, new Rectangle(0, 0, width, height));
} catch (Exception ex) {
ex.printStackTrace();
}
}
I couldn't find a single answer on the internet, so I don't know what's going wrong. :(
Thank you very much for your support.