How to make JLabel with image fill BorderLayout.CENTER

前端 未结 2 1183
眼角桃花
眼角桃花 2021-01-13 03:23

Ive got a JFrame and set the LayoutManager to BorderLayout and then proceeded to add my JLabel with an image. However when i resize the frame the JLabel doesnt resize. I hav

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 03:52

    Best option is to sub class ImageIcon and override its paintIcon method to simply paint the image using the Graphics.paint( x, y, width, height ...).

提交回复
热议问题