aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Making an image background Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Making an image background" Watch "Making an image background" New topic
Author

Making an image background

Stephen Fox
Greenhorn

Joined: Oct 08, 2012
Posts: 2
Hey I'm new to CodeRanch and relatively new to Java code (5 months of basic stuff).

I asked on YahooAnswers and I was presented with this code:




The imports are all good, I just need what I should be doing with this code. If you have a better code example that would be appreciated. Again I'm just trying to place an image(jpeg) in the background of an art program I'm trying working on, that of which I'll ask for help seperately
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Hi Stephen, welcome to the Ranch!

Here's what I would suggest you do. Now that you've found that code -- which is a pretty good basis for what you'll want to do -- put it aside until you are ready to use it. (Right now you aren't ready, as I'm sure you would agree.) Next, write your application without the image-background feature. Once you have that working, then it's time to merge in the code which does the image background.

Note that the code you found uses a JPanel. So your application should be using a JPanel to display the part of the GUI where you want the image to appear. But beyond that requirement, don't worry about anything else until you get something working.

If at that point you still don't know how to make use of that code, well, that wouldn't be too surprising for a beginner. So drop back in here and we can talk about it then.
Stephen Fox
Greenhorn

Joined: Oct 08, 2012
Posts: 2
Paul Clapham wrote:Hi Stephen, welcome to the Ranch!

Here's what I would suggest you do. Now that you've found that code -- which is a pretty good basis for what you'll want to do -- put it aside until you are ready to use it. (Right now you aren't ready, as I'm sure you would agree.) Next, write your application without the image-background feature. Once you have that working, then it's time to merge in the code which does the image background.

Note that the code you found uses a JPanel. So your application should be using a JPanel to display the part of the GUI where you want the image to appear. But beyond that requirement, don't worry about anything else until you get something working.

If at that point you still don't know how to make use of that code, well, that wouldn't be too surprising for a beginner. So drop back in here and we can talk about it then.


Hey Paul thanks man, really helpful! I've only got one issue: I'm not building a graphical user interface. I'm drawing this fairly ugly house using GObject classes. I just want the image behind my house, as to put it, for example, under water. Just trying something different. Thanks again.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18662
    
    8

Well, in that case what you found is completely irrelevant. You're going to have to look for solutions which involve GObject and not Java.

Although I know nothing at all about GObject. My quick google and review didn't tell me how Java was relevant to GObject, or even for that matter how you could draw any pictures at all in GObject. But anyway, if you aren't building a GUI then answers involving Swing GUI coding are definitely useless.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making an image background