java中swing组件设置icon自适应按钮大小

代码如下:

ImageIcon icon1 = new ImageIcon(curDir + "/img/folder.png");
Image img = icon1.getImage();
Image newimg = img.getScaledInstance(width,height,java.awt.Image.SCALE_SMOOTH); 
ImageIcon icon = new ImageIcon(newimg); 
JButton button = new JButton(icon);
原文地址:https://www.cnblogs.com/liyuanhong/p/12120517.html