Forums Register Login

Trying to put a jButton above an image

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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))

+Pie Number of slices to send: Send
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 ?
+Pie Number of slices to send: Send
In your original code you where using "image/c.jpg". Maybe the message is saying it can't find the "c.gif"?
+Pie Number of slices to send: Send
No i tried both thought maybe there is a problem with jpgs but thats not it
+Pie Number of slices to send: Send
Hint: Class#getResource(...) returns a URL.
+Pie Number of slices to send: Send
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 ??
+Pie Number of slices to send: Send
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
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 7201 times.
Similar Threads
Retriving jTextfield value from an other java file
Learning NetBeans JavaForms
Dynamic textfield creation
JComboBox help
report creating
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:50:43.