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);
博客里大都是转载的内容,其目的主要用户知识的组织和管理。