Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resolved FXML question.

Joined
Nov 6, 2015
Messages
583
Hi there,

I am trying to use the EmbeddableUI this is working fine, but I want to use it to display my progress report on, so I tried it like this:

Code:
@FXML
    private Label profitLabel;

Code:
public boolean updateGui() {
       
        if (profitLabel != null) {
            System.out.println("The label is: " + profitLabel);
            int realProfit = Constants.berryPrice*Constants.berryCollected;
            profitLabel.setText("Profit made: " + realProfit);

        }
        return true;

    }

And it is being executed at my first Tasks get's validated, because I didn't knew how to make it loop like every second without LoopingScript.

Execute:
Code:
BerryCollecter gui = new BerryCollecter();
        gui.updateGui();

For some odd reason it keeps returning the value of the label as NULL, I already got the ID created in the .fxml, so I have no clue how to solve this problem, I hope you guys can help me.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,053
You should not be updating it every X seconds. You should only update it when the value updates. As far as why the Label is returning null, we'll need to see the FXML as well.
 
And the EmbeddableUI implementing class.
 
You're likely not loading the FXML into the class.
 
Joined
Nov 6, 2015
Messages
583
He forgot to assign fx:ids to his Label elements.

Not really, it was because I called my updateGui(); from another class this is where it got screwed up(Hence why it
was saying null), I had resolved that error by using this:

Code:
new LoopingThread((Runnable) () -> {
            Platform.runLater(() -> {
                updateGui();
            });
        }, 1000, 2000).start();

Because of this added on my OnStart of my main class it was called within the same class which fixed me error.
 
Top