如何制作 AWT Button() 并使用 ImageIcon()、Icon()? [英] How to make AWT Button() and use ImageIcon(), Icon()?

查看:12
本文介绍了如何制作 AWT Button() 并使用 ImageIcon()、Icon()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 GIF 图像应用到我的 AWT Button?

How can I apply a GIF image to my AWT Button?

AWT:不起作用

    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 与 Swing 有点不同.

AWT is a bit different from Swing.

没有构造函数 button(image),因此您不工作".

There's no constructor button(image), hence your "not working".

看看了解如何使用您自己的图像按钮扩展 AWT 以了解如何在 AWT 按钮上制作该图像.

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 Button() 并使用 ImageIcon()、Icon()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆