Call static content
Tom Schindl
tom.schindl at bestsolution.at
Sat Aug 24 12:41:57 PDT 2013
This is more a user group question! A node can be shown only in one
place. If you want to reuse the same image load the image into
javafx.scene.Image and set it to different ImageView-Nodes.
Tom
On 24.08.13 21:01, Peter Penzov wrote:
> I have this code from JavaFX application:
>
> private static final ImageView ncpic;
> static {
> ncpic = new
> ImageView(TabContent.class.getResource("/images/6.jpg").toExternalForm());
> }
>
> I noticed that I can use this picture only once. When I use it twice the
> scene where I call it it's empty. How I can use this picture twice or more
> times? Maybe this is caused by the static java method which I call to
> display the picture?
>
> quick example:
>
> public class TabContent {
>
> private static final ImageView ncpic;
> static {
> ncpic = new
> ImageView(TabContent.class.getResource("/images/6.jpg").toExternalForm());
> }
>
> private static StackPane generalConfiguration() {
>
> StackPane stack = new StackPane();
> stack.getChildren().addAll(ncpic); // Add the picture
> and the Label
> return stack;
> }}
>
> I use it this way: TabContent.generalConfiguration() And second time in
> different Java Class.
>
More information about the openjfx-dev
mailing list