Adding an image to a panel using Java AWT

Tyler picture Tyler · Mar 29, 2009 · Viewed 10.3k times · Source

I posted earlier about having a really messed up panel but, I fixed that by simply changing the layout (thank you to Charlie Martin for helping me). Now, I'm trying to add an image to a panel, so I can add that panel to the frame. This is part of the class that I am messing around with.

http://friendpaste.com/13zibFC4oVxCbm83500KVj (dead link)

This is what comes up when I run the program and hit start game (on the startup popup).. screenshot

Essentially, there is supposed to be an image on the main window along with the buttons and I'm not exactly sure how I would go about implementing this.

Answer

Tom picture Tom · Mar 30, 2009

I'd probably just set an ImageIcon on a JLabel and add the JLabel where you want in the panel.