Scale the ImageIcon automatically to label size
问题 On my JFrame, I am using the following code to display an image on the Panel : ImageIcon img= new ImageIcon(\"res.png\"); jLabel.setIcon(img); I would like to \"auto-size\" the picture in the label. Indeed, sometimes the image size is only few pixel, sometimes well more. Is there a way to set the size of the label, and then to autosize the image in the label? 回答1: This is a tricky question. You highlight the fact that you are using a JLabel to show the image, which is the standard way of