0

i'm using Netbeans and it's GUI designer tool,i want to add a picture to my background JPanel but i can't get into the code (It's grayed out and unchangeable) so the normal "add image" won't work. Also i tried to use a Label but that didn't work out either.

Or is simply my code to add it wrong?

BufferedImage biBackground= ImageIO.read(new File("path-to-file"));
JLabel biBackground= new JLabel(new ImageIcon(myPicture));
add(biBackground);

so i don't know where to put my code, because i cant add something to the "Initcomponents()" method

I'm sorry for the dumb question.

Barett
  • 5,826
  • 6
  • 51
  • 55
Kyo Akashi
  • 213
  • 1
  • 2
  • 13
  • 1
    with correct [path-to-file](http://stackoverflow.com/questions/9864267/load-icon-image-exception/9866659#9866659) works (by @nIcE cOw) – mKorbel Nov 06 '14 at 08:18
  • but my problem is i dont know where to put the code because i cant get into "Initcomponents()" method – Kyo Akashi Nov 06 '14 at 08:19
  • 1
    @MadProgrammer are you sure that your NIC is unique, because we have here own, and excelent person [MadProgrammer](http://stackoverflow.com/tags/swing/topusers), really not good idea in this case .... – mKorbel Nov 06 '14 at 08:22
  • milion times here "Don't to use generated code", otherwise follows Netbeans tutorial about Mattise, :-) search on Netbeans forum – mKorbel Nov 06 '14 at 08:23
  • @mKorbel sorry could not understand NIC??? – dReAmEr Nov 06 '14 at 08:25
  • okay, sorry, i thought it would be easier for a newbe with this ^^' – Kyo Akashi Nov 06 '14 at 08:25
  • (asier for a newbe) - not this Framework is long time depreciates, – mKorbel Nov 06 '14 at 08:26
  • @MadProgrammer (sorry could not understand NIC???) - some really and unique identifier, for unambiguous identification – mKorbel Nov 06 '14 at 08:28
  • 2
    @MadProgrammer Mkorbel is asking why you're using my user name ? – MadProgrammer Nov 06 '14 at 09:10
  • You don't have to add content into the initComponent method, you can perform modifications after it. Adding a background image is normally done by extending a class from JPanel and overriding its paintComponent method and painting the image there – MadProgrammer Nov 06 '14 at 09:14
  • I was not aware of that,Because when i changed my name last time SO did not display any unique error or like that,now it is not allowing me to change, only after six days may be some policy.. – dReAmEr Nov 06 '14 at 09:17

0 Answers0