Results 1 to 2 of 2
- 04-01-2011, 12:58 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
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");
g.drawImage(bgImage1);
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.
Thanks
-
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.
Similar Threads
-
[Help] W/ background image
By gundum584 in forum New To JavaReplies: 9Last Post: 01-10-2011, 05:48 AM -
unable to change the TextArea.background !
By Y. Progammer in forum New To JavaReplies: 2Last Post: 02-28-2010, 04:55 PM -
Background image
By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 05:49 PM -
Image as background
By Java.child in forum AWT / SwingReplies: 2Last Post: 10-02-2008, 11:37 PM -
Why this image background is black ?
By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 04:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks