twin yan
,
Greenhorn
Mar 04, 2013 23:12:57
hello ,
i'm trying to make a small game ,
i never done this before and got mixed up in the menus
i tried to make a background image and it worked
now i'm trying to put a jbutton on top of the background picture
and it won't show the button i'm guessing it's not on top
any ideas how to solve it ?
here's what i did to get the background image ( the rest is mostly netbeans auto)
thanks to all helpers
Michael Dunn
,
Ranch Hand
Mar 04, 2013 23:20:48
another way is to use a Jpanel to paint the image as its background, then add components as normal
here's a very simple demo
(the BackgroundPanel class is from this forum's FAQ (main page))
twin yan
,
Greenhorn
Mar 05, 2013 02:17:57
ok i tried it this way but when i run it , it doesn't show the background picture
and in the exception it's saying
java.net.MalformedURLException: no protocol: images/c.gif
any ideas why or what that means ?
Rob Camick
,
Rancher
Mar 05, 2013 09:01:54
In your original code you where using "image/c.jpg". Maybe the message is saying it can't find the "c.gif"?
twin yan
,
Greenhorn
Mar 05, 2013 09:20:36
No i tried both thought maybe there is a problem with jpgs but thats not it
Darryl Burke
,
Bartender
staff
Mar 05, 2013 10:47:53
Hint: Class#getResource(...) returns a URL.
twin yan
,
Greenhorn
Mar 05, 2013 16:04:53
been sitting on it for hours , still no idea
now it's saying :
java.lang.IllegalArgumentException: input == null!
i tried
and
both doing the same input == null!
the folder and file name is correct
any ideas ??
Michael Dunn
,
Ranch Hand
Mar 05, 2013 20:07:55
go back to my demo code and run it again, replacing *all* occurrences of "Test.gif" with
"images\\c.jpg"
not
"images/c.jpg"
remember it's *all* occurrences