开发者

What's the Java equivalent of this declaration in Flex

开发者 https://www.devze.com 2023-04-12 10:04 出处:网络
[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
[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

精彩评论

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