挥杆:创造“纪录”和“停止”按钮

发布于 2024-09-19 10:57:13 字数 256 浏览 2 评论 0原文

我看到有一个 JButton 构造函数Icon 作为参数...但是如何从位图文件中获取 Icon

另外,默认外观中是否有“记录”和“停止”图标?还是我必须自己提供?

I see that there is a JButton constructor which takes an Icon as a parameter... but how do I get an Icon from a bitmap file?

Also, are there "record" and "stop" Icons available from the default look and feel? or do I have to provide them myself?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ヅ她的身影、若隐若现 2024-09-26 10:57:14

您可以从 URL 创建 ImageIcon等(包括文件名或字节数组)。

您还可以将任何图像传递到构造函数中,这意味着您可以充分利用 ImageIO 实用程序类。

You can create an ImageIcon from a URL, among other things (including a filename or a byte array).

You can also pass any Image into the constructor, meaning you can take full advantage of the ImageIO utility class.

夜还是长夜 2024-09-26 10:57:14

您可以从 L&F 中按名称获取图标,如下所示以及此示例中。

Icon icon = UIManager.getIcon("OptionPane.errorIcon");

您可以使用 Rob Camick 方便的 UIManager 默认值

附录:另一种方法是实现 Icon 接口并使用 Graphics2D 原语绘制图标,如图

You can get icons by name from the L&F, as shown below and in this example.

Icon icon = UIManager.getIcon("OptionPane.errorIcon");

You can see what's available using Rob Camick's handy UIManager Defaults.

Addendum: Another approach is to implement the Icon interface and draw the icon using Graphics2D primitives, as shown here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文