Resize a picture to fit a JLabel

后端 未结 8 556
不思量自难忘°
不思量自难忘° 2020-11-29 01:56

I\'m trying to make a picture fit a JLabel. I wish to reduce the picture dimensions to something more appropriate for my Swing JPanel.

I tried with setPreferredSiz

8条回答
  •  执念已碎
    2020-11-29 02:35

    Assign your image to a string. Eg image Now set icon to a fixed size label.

    image.setIcon(new javax.swing.ImageIcon(image.getScaledInstance(50,50,WIDTH)));
    

提交回复
热议问题