如何让AWT按钮()和使用的ImageIcon(),()图标? [英] How to make AWT Button() and use ImageIcon(), Icon()?
本文介绍了如何让AWT按钮()和使用的ImageIcon(),()图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何申请一个GIF图像到我的AWT 按钮
?
AWT :不工作
图标warnIcon =新的ImageIcon(/ src目录/ world.gif);
按钮按钮1 =新按钮(warnIcon); 图标warnIcon =新的ImageIcon(/ src目录/ world.gif);
JButton的按钮1 =的新的JButton(warnIcon);
解决方案
AWT是一个有点摇摆,从不同的。
有没有构造按钮(图片)
,因此你的不工作。
看一看的 了解如何用自己的图像按钮扩展AWT 的,看看如何在AWT按钮图像。
How can I apply a GIF image to my AWT Button
?
AWT: does not work
Icon warnIcon = new ImageIcon("/src/world.gif");
Button button1 = new Button(warnIcon);
Icon warnIcon = new ImageIcon("/src/world.gif");
JButton button1 = new JButton(warnIcon);
解决方案
AWT is a bit different from Swing.
There's no constructor button(image)
, hence your "not working".
Take a look at Learn how to extend the AWT with your own image buttons to see how to make that image on a AWT button.
这篇关于如何让AWT按钮()和使用的ImageIcon(),()图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文