Results 1 to 2 of 2
  1. #1
    MrPremium is offline Member
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Default 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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. [Help] W/ background image
    By gundum584 in forum New To Java
    Replies: 9
    Last Post: 01-10-2011, 05:48 AM
  2. unable to change the TextArea.background !
    By Y. Progammer in forum New To Java
    Replies: 2
    Last Post: 02-28-2010, 04:55 PM
  3. Background image
    By leiferouis in forum New To Java
    Replies: 9
    Last Post: 03-08-2009, 05:49 PM
  4. Image as background
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-02-2008, 11:37 PM
  5. Why this image background is black ?
    By samson in forum Java 2D
    Replies: 1
    Last Post: 07-17-2007, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •