[Embed("assets/BorderContainer.png")]
public const BorderContainerIcon:Class;
The xml string of my application menu is formed entirely in java and I can't the iconField="@icon" property of the menuBar component otherwise. It has to be there.
EDIT: I'm shamefully sorry for开发者_运维技巧 that phrasing.
If I'm understanding you correctly, you're looking for a way to embed a resource in a Java class.
The Java compiler won't automatically embed resources in a class file. However, you can package BorderContainer.png
into a .jar file along with the rest of your program. A .jar file is the most common way of distributing client-side executable Java programs (fun fact: a .jar file is just a disguised .zip file). Then you can access BorderContainer.png
from your class by using Class.getResourceAsStream("BorderContainer.png")
.
精彩评论