JavaFX 应用程序图标 [英] JavaFX Application Icon

查看:43
本文介绍了JavaFX 应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 JavaFX 更改应用程序图标,还是必须使用 Swing 来完成?

Is it possible to change the application icon using JavaFX, or does it have to be done using Swing?

推荐答案

假设您的舞台是舞台"并且文件在文件系统上:

Assuming your stage is "stage" and the file is on the filesystem:

stage.getIcons().add(new Image("file:icon.png"));

根据下面的评论,如果它被包装在一个包含 jar 中,您将需要使用以下方法:

As per the comment below, if it's wrapped in a containing jar you'll need to use the following approach instead:

stage.getIcons().add(new Image(<yourclassname>.class.getResourceAsStream("icon.png")));

这篇关于JavaFX 应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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