Java Tutorial | Custom Background for JFrame | Simple way (Made Easy)

preview_player
Показать описание
*Error Fix and Code Below*
If your JFrame doesn't view the components i.e JButton,JTextField...etc., please change the layout of your JFrame below the setContentPane to FlowLayout(). By default JFrame are set to BorderLayout which is limited to 5 locations.
Here is Code for the Fix:
In this tutorial I will be applying a custom to a JFrame, So Enjoy and misconceptions about the tut, please notify me.
Рекомендации по теме
Комментарии
Автор

Thank you my friend, you have no idea how I was rescued. I clambered all of Russia's network and still did not find until you've stumbled on your video.

ДмитрийМеркурьев-вы
Автор

now i used this method to set as background image but it is covering the text fields and labels that i had before 

ShubhankShukla
Автор

OH MY GOD!
ONE BILLION THANKS!!! This made my day!! This was driving me crazy and it was really helpful, because I was using a JPanel, and this solution is much simpler, easier and efficient. BTW, I did it even more simpler, just using an ImageIcon:
JLabel bg = new JLabel(new ImageIcon(path+filename));
By doing this, you dont need to use Files, IOImage nor catch exceptions. Give it a try! ;)
Thanks again! :D

SIrcam
Автор

You would need to make a resources folder and put all your photos and music etc in their so when you export it, the files go into the jar or what ever you are doing, to make a resources file right click your project then go to the Java Build path tab and then click add class folder and Create new folder and name it res or resources, and then put all your images, music, etc into that folder, Hope it helped!

samuelarminana
Автор

It depends on how you declare your JFrame, if you're inheriting from it then no need to declare it as an object. Other note, allot of people make errors.

ismailzd
Автор

I wonder if this technique work with JPanel as i wish to have a Frame and lets say 4 different pictures inside.

vladeb
Автор

When adding the panel to the frame, they all start with this.whatever and i'm not sure what "this" is the name of. I want to be able to change the names of things so i can replicate them elsewhere. Can anyone help me?

AAGameZone
Автор

Thanks dude, I suggest you use a different approach for laying out your Panels, the fact you're setting the setContentPane to a background it wouldn't be able to override. For example I was forced to put my background on BorderLayout.NORTH. other ways of putting it, is using netbeans as it's simply pick and drop you can modify the code on the background. I hope I helped

ismailzd
Автор

it works but it its dosnt show text fields and stuff ... thanx any way

iVodkaBeerMaikMB
Автор

do you know how to implement the picture to the project?

DieFriiks
Автор

I've a question:
If you export it in a jar file and the people are downloading it (for example), will they see your pic or not?

LordRixuel
Автор

Awesome video + Explanation
But there's a problem for me I m trying to apply cardlayout to the panels put on the frame
I've tried setBounds method too to set the label for background but didn't show until I resized the frame. By applying this method (your method) I get a Panel above the background with the intended buttons. I ve to make that panel transparent, don't i?
or there is  something else that i can

priyankkharat
Автор

awesome background you got in there ! :D

ralpjeff
Автор

adding a JLabel means rest ofthe components need to be added to and arrange according to the label and not the frame. thats giving me tons of errors
plz help

omkarwadekar
Автор

Showing error like file cannot be resolved to a type in reading image statement

kothapallivijayakumar
Автор

how can we align this photo to the left? The JFrame I am working with is larger, tho I want to display a photo partially on the background. How can I align a background image to the far left? 

jonxeryus
Автор

and how to add elements to this frame? where is the most important part about layout>?

googolify
Автор

Thank you man You save my  butt on a collage assingment!!!

videoselcolo
Автор

I successfully installed image background but the problem is all my JfieldTxt and button are gone only background Display

rgcasiadotaallstar
Автор

My buttons lost position because of the FlowLayout...
Is there a way to fix this? they are all in a row, as its supposed to be, but i need them in a certain position
Please help

hopefulrecovery