Results 1 to 2 of 2
- 04-01-2011, 01:58 AM #1Member
- Join Date
- Apr 2011
- Rep Power
Unable to set image as background
Hi, I am making a java game for school which require myself to have a background image. I keep on getting the same error no matter what I try or change. It keeps saying Identifier Expected.
Here are snippets of my code:
static Image = bgImage1;
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
Toolkit tk = Toolkit.getDefaultToolkit();
bgImage1 = tk.getImage("sprites/background.jpg");
The error comes from the "static Image = bgImage1;" saying an Identifier is Expected. If you think you know the problem but need more information, I'd be glad to throw more details.
You are not using valid Java syntax. You have static then a class name but no variable name. Time to hit the tutorials a bit and they'll show you how to do this right.
- By gundum584 in forum New To JavaReplies: 9Last Post: 01-10-2011, 06:48 AM
- By Y. Progammer in forum New To JavaReplies: 2Last Post: 02-28-2010, 05:55 PM
- By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 06:49 PM
- By Java.child in forum AWT / SwingReplies: 2Last Post: 10-03-2008, 12:37 AM
- By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 05:24 AM