Adding an image to a panel using Java AWT

10,365

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

Share:
10,365
Tyler
Author by

Tyler

Updated on June 04, 2022

Comments

  • Tyler
    Tyler almost 2 years

    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.

  • Tyler
    Tyler about 15 years
    Well, I don't need all of the features you said "It will also allow you to set the specific size if you want; it will scale the image to best fit the panel, and align the image as well."... All I'm trying to do is add an image under the buttons in the program. -_-