enon
enon

Reputation: 451

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.

Upvotes: 0

Views: 141

Answers (1)

Jack Edmonds
Jack Edmonds

Reputation: 33171

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

Upvotes: 2

Related Questions