【发布时间】:2016-01-24 09:49:16
【问题描述】:
我正在使用命令.setIcon() 将图像应用到 JLabel,然后将标签添加到面板
public browser() throws IOException {
JLabel lblimg;
Image img;
ImageIcon ico;
img = ImageIO.read(new File("<FilePath>"));
ico = new ImageIcon(img);
lblimg.setIcon(ico);
lblimg.setBounds(300,90,120,120);
add(lblimg);
}
但这不会调整标签内的图像大小,这样如果大于标签大小,只会出现图像的一部分。
有谁知道将图像插入标签背景并调整图像大小的方法?
【问题讨论】:
标签: java image swing icons jlabel