Is it possible to change the application icon using JavaFX, or does it have to be done using Swing?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can easily put icon to your application using this code line
stage.getIcons().add(new Image("image path") );
images folder need to be in Resource folder.
If you got
Invalid URL or resource not found
put your icon.png in the "bin" folder in your workspace.Full program for starters :) This program set Stack Overflow Icon.
Output Screnshot
No need to change the code. It still works fine. Tested and verified in Java 1.8(1.8.0_45). Path can be set to local or remote both are supported.
OR
Hope it helps. Thanks!!
Assuming your stage is "stage" and the file is on the filesystem:
As per the comment below, if it's wrapped in a containing jar you'll need to use the following approach instead:
I tried this and it totally works. The code is:
icon.png is under the same folder as the source files.