java 如何用swing创建一个带图标的按钮

如题所述

JButton有个构造函数是JButton(Icon icon),就是用来创建带图标的按钮的。
可以这样用,如:
JButton jb = new JButton(new ImageIcon("images/myImage.gif"));
这样得到的就是带图标的按钮了。
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-04-09
JButton btn = new JButton(new ImageIcon(this.getClass().getResource("../images/logo.gif")));
第2个回答  2012-04-18
写个类继承jpael 在创建对象添加到里面
相似回答