这是代码
btnVoltar.setIcon(new ImageIcon(AdicionarRefeição1.class.getResource("/icons/Back Icon.png")));
我想调整它的大小以使其适合标签,但太大了。
答案 0 :(得分:0)
您可以在此处尝试使用此代码,但随后该帖子还是stackoverflow的重复内容
private ImageIcon image; // where in your case it's your class resource
Image IMG = image.getImage(); // transform it
Image newimg = IMG.getScaledInstance(200, 200, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way
//Change the 200,200 to the number you prefer to resize it to
image = new ImageIcon(newimg); // transform it back