1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Resolved FXML question.

Discussion in 'Developer Support' started by Remco1337, Oct 20, 2016.

  1. Remco1337

    Joined:
    Nov 6, 2015
    Messages:
    506
    Likes Received:
    11
    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 (Text):
    1. @FXML
    2.     private Label profitLabel;
    Code (Text):
    1. public boolean updateGui() {
    2.        
    3.         if (profitLabel != null) {
    4.             System.out.println("The label is: " + profitLabel);
    5.             int realProfit = Constants.berryPrice*Constants.berryCollected;
    6.             profitLabel.setText("Profit made: " + realProfit);
    7.  
    8.         }
    9.         return true;
    10.  
    11.     }
    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 (Text):
    1. BerryCollecter gui = new BerryCollecter();
    2.         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.

     
  2. Best Answer:
    Post #5 by Party, Oct 21, 2016
  3. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,938
    Likes Received:
    1,266
    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.
    --- Double Post Merged, Oct 20, 2016, Original Post Date: Oct 20, 2016 ---
    And the EmbeddableUI implementing class.
    --- Double Post Merged, Oct 20, 2016 ---
    You're likely not loading the FXML into the class.
     
  4. Remco1337

    Joined:
    Nov 6, 2015
    Messages:
    506
    Likes Received:
    11
    I solved it already, thanks!
     
  5. Jhinn

    Joined:
    Jun 9, 2015
    Messages:
    3,648
    Likes Received:
    1,337
    Could you post your solution here? Other people might run into the same problem and when they see your solution they can fix it too :)
     
    Arbiter and Aidden like this.
  6. Party

    Party Client Developer

    Joined:
    Oct 12, 2015
    Messages:
    3,708
    Likes Received:
    1,606
    He forgot to assign fx:ids to his Label elements.
     
    Jhinn likes this.
  7. Remco1337

    Joined:
    Nov 6, 2015
    Messages:
    506
    Likes Received:
    11
    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 (Text):
    1. new LoopingThread((Runnable) () -> {
    2.             Platform.runLater(() -> {
    3.                 updateGui();
    4.             });
    5.         }, 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.
     
    LucasSousa likes this.

Share This Page

Loading...