• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I add a background image to an applet ?  RSS feed

 
Lee Sigauke
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been trying to make an applet that converts sterling to euro and vice versa, now I'm trying to put a background on the applet and I can't figure out how to, I've tried many snippets of code like this but I can't figure out how to add them to the container or to make them show up.

The applet started as a JFrame.



MAIN PROGRAM




CONVERSION CLASS


 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going to post a link but there were so many to choose from when I googled for jpanel background image, I thought I would let you choose.

The "body" JPanel is the one you want to add the background image to, I think.
 
Lee Sigauke
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I was going to post a link but there were so many to choose from when I googled for jpanel background image, I thought I would let you choose.

The "body" JPanel is the one you want to add the background image to, I think.


I've looked through a lot of results and most of them have me creating an entire class which looks pretty big and makes the whole thing more complicated than I think it would be.

Most of the methods I've tried just end up giving me a white screen when I run the applet, this is also not a resource issue because I've tried running sample programs and the images load fine, it's just a problem when I try adding it to my applet

I also have a container here and having them co-exist is baffling me
 
Paul Clapham
Sheriff
Posts: 22823
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lee Sigauke wrote:I've looked through a lot of results and most of them have me creating an entire class which looks pretty big and makes the whole thing more complicated than I think it would be.


Well, yeah, I'm pretty sure all of them will be overriding the paintComponent method of some component, probably JPanel. And that does mean you're going to have a class to do the overriding in. But I don't see why you're dismissing that as "complicated"... you already have an anonymous inner class in your posted code, so I don't see what your objection is. You can do this with another anonymous inner class if you like.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!