JPanel background image

前端 未结 2 1975
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 23:54

This is my code, it indeed finds the image so that is not my concern, my concern is how to make that image be the background of the panel. I\'m trying to work with Graphics

2条回答
  •  自闭症患者
    2020-12-12 00:22

    If you are just going to draw the image at its original size then all you need to do is add the image to a JLabel and then use the label as a Container by setting its layout manager.

    The only time you need to do custom painting is if you want to scale or tile the background image or do some other fancy painting.

    See Background Panel for more information on both approaches.

    also, check out the section from the Swing tutorial on Custom Painting.

提交回复
热议问题