Tutorial Implementing Embeddable UI

Discussion in 'Tutorials & Resources' started by SlashnHax, Apr 7, 2016.

  1. Feel free to ask any questions.
    TheVTM and Derk like this.
  2. Thanks mayte, I will take a look at it as soon as I get home.
  3. Great video.

    Any chance you could make a #2 that demonstrates the a gui controller for EmbeddableUI that has a few config buttons and a bot status update ?
  4. There is nothing RuneMate specific about the JavaFX controller. You should be able to find plenty of tutorials online on how to set up and use JavaFX controllers online.
  5. Scene Builder can also generate a controller for your design.
  6. I followed the video and got this error
    Gyazo - 9fec431ad6da5e31e016d0e2e15dc08c.png

    I'm assuming its because my controller was made without embeddableUI in mind.

    EDIT: I got my controller working now. But would be nice to know how to do all that spiffy stuff like show profit /xp now that there is no paint. Or even a status
    #6 blisterz, Apr 25, 2016
    Last edited: Apr 25, 2016
  7. new guiController(this)
  8. Why is botInterfaceProperty never called? I do see the UI in Spectre, but that's about it.
    Code (Java):
    1. package com.skelware.runemate.script.staking;
    3. import com.runemate.game.api.client.embeddable.EmbeddableUI;
    4. import com.runemate.game.api.hybrid.util.Resources;
    5. import com.runemate.game.api.script.framework.LoopingScript;
    6. import com.skelware.runemate.script.staking.ui.UIController;
    7. import javafx.beans.property.ObjectProperty;
    8. import javafx.beans.property.SimpleObjectProperty;
    9. import javafx.fxml.FXMLLoader;
    10. import javafx.scene.Node;
    11. import javafx.scene.Parent;
    13. import java.io.IOException;
    14. import java.io.InputStream;
    16. public class StakingSalvation extends LoopingScript implements EmbeddableUI {
    18.     private ObjectProperty<? extends Node> ui;
    20.     public StakingSalvation() {
    21.         this.setEmbeddableUI(this);
    22.     }
    24.     @Override
    25.     public void onLoop() {
    27.     }
    29.     @Override
    30.     public void onStop() {
    31.         System.out.println("stop");
    32.     }
    34.     @Override
    35.     public ObjectProperty<? extends Node> botInterfaceProperty() {
    36.         System.out.println("botInterfaceProperty");
    38.         if (ui == null) {
    39.             try {
    40.                 final FXMLLoader loader = new FXMLLoader();
    41.                 final InputStream input = Resources.getAsStream("com/skelware/runemate/script/staking/ui/UIDocument.fxml");
    42.                 final Parent document = loader.load(input);
    44.                 loader.setController(new UIController());
    45.                 ui = new SimpleObjectProperty<>(document);
    46.             } catch (final IOException e) {
    47.                 e.printStackTrace();
    48.             }
    49.         }
    51.         return ui;
    52.     }
    53. }
  9. If you can see it, the method must have been called.
  10. Well system out did not log anything to the console, but the "stop" is logged to the console. So it most definitely is not called, unless system out is suppressed at certain stages, @Cloud?
  11. What else would load the fxml then? Welp I know nothing further so I will leave this here :rolleyes:
  12. Yeah it just seems like system out is not passed through. If I create a deliberate error in my controller's constructor it logs the error correctly with the expected stack trace.
  13. When I first tried the tutorial, I had the same problem as this Gyazo - 9fec431ad6da5e31e016d0e2e15dc08c.png, since my controller is looking for a botand stage to be passed in. Probably because it wasn't made with EmbeddableUI in mind. I changed the constructor on that to not require those and not pass in or set a script bot & stage (not sure if that was the right thing to do but all errors cleared) and now when I run the bot my UI doesn't pop up and I run into

    Code (Text):
    2. javafx.fxml.LoadException:
    3. unknown path
    5.    at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
    6.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
    7.    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
    8.    at com.deathizpro.bots.EmbeddableUITutorial.EmbeddableUITutorial.botInterfaceProperty(EmbeddableUITutorial.java:28)
    9.    at nul.iIIiiIiIIIii.initialize(nvb:233)
    10.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    11.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
    12.    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
    13.    at nul.IiiIIiiiiiii.try(gp:140)
    14.    at nul.IiiIIiiiiiii.try(gp:146)
    15.    at nul.iIIiiIiIIIii.<init>(nvb:150)
    16.    at nul.iIiiIIiIIIiI.try(vgc:78)
    17.    at nul.IIIiIIiIIiii.try(bub:1)
    18.    at nul.IiIiiIiiIiiI.try(ltb:17782)
    19.    at nul.IiIiiIiiIiiI.call(ltb:1177)
    20.    at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
    21.    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    22.    at java.lang.Thread.run(Thread.java:745)
    23. Caused by: java.lang.NullPointerException
    24.    at com.deathizpro.bots.EmbeddableUITutorial.TestUIController.initialize(TestUIController.java:21)
    25.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    26.    ... 16 more
    which is the same problem I have here Question - javafx.fxml.LoadException: unknown path
  14. One or more of your FXML elements isn't properly declared, most likely.
    --- Double Post Merged, May 28, 2016, Original Post Date: May 28, 2016 ---
    Use this to make sure you're declaring all your elements.

  15. Should I be declaring the anchorpane and label as well? My Gui only has 1 label, 1 button, 1 combobox, and the anchorpane itself. Without the anchorpane and label declared my skeleton looks like


    And my controller class looks like

  16. You're missing the @FXML annotations.
    Serene likes this.
  17. Gotcha. I'll try that.
    --- Double Post Merged, May 28, 2016 ---
    That fixed it. Thanks guys.

Share This Page