开发者

What's the Java equivalent of this declaration in Flex

[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").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜