Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By pj6444

Thread: Placing code on top of a background image in JSwing

  1. #1
    LetsG0Blue is offline Member
    Join Date
    Feb 2013
    Posts
    68
    Rep Power
    0

    Default Placing code on top of a background image in JSwing

    I'm making a pong game but I would like to use a basketball court image behind my code to give it a prettier look (the ball is also a basketball), but I can't seem to get my code to appear on top of my basketball court image, the image just overlaps my code. How could I go about fixing this? Any suedo code will help.

  2. #2
    pj6444 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    164
    Rep Power
    2

    Default Re: Placing code on top of a background image in JSwing

    Are you using the Graphics class? If so, just do your g.drawImage(image, x, y, width, height, ImageObserver); before you draw the ball. This will draw the court first and then draw the ball afterwards.
    zFollette likes this.

  3. #3
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Placing code on top of a background image in JSwing

    Quote Originally Posted by pj6444 View Post
    Are you using the Graphics class? If so, just do your g.drawImage(image, x, y, width, height, ImageObserver); before you draw the ball. This will draw the court first and then draw the ball afterwards.
    In addition: Anything you add will overlap the last thing you added, so add items wisely.

Similar Threads

  1. trouble placing a loop in code
    By james75 in forum New To Java
    Replies: 1
    Last Post: 07-08-2012, 09:20 PM
  2. jswing window problem
    By mohitgupta1989 in forum New To Java
    Replies: 3
    Last Post: 06-25-2010, 02:05 PM
  3. Placing a JProgressBar over my JPEG image
    By hitmen in forum AWT / Swing
    Replies: 7
    Last Post: 03-08-2009, 10:16 AM
  4. Placing java code/html pages on website host
    By Bomber_Will in forum New To Java
    Replies: 8
    Last Post: 11-30-2008, 04:31 PM
  5. Image as background
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-02-2008, 11:37 PM

Posting Permissions

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