java swing 创建带图标的按钮?

如题所述

jButton.setBounds(0, 0, 85, 82);
         ImageIcon icon = new ImageIcon("E:\\workspace\\weixin-admin-pom\\src\\main\\java\\com\\swing\\dl.png"); 
         Image temp = icon.getImage().getScaledInstance(jButton.getWidth(),  
                 jButton.getHeight(), icon.getImage().SCALE_DEFAULT);  
         icon = new ImageIcon(temp);
        jButton.setIcon(icon);

温馨提示:答案为网友推荐,仅供参考
相似回答