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

Question unknown path error to fxml file + npe error to img file when trying to test EmbeddableUI

Discussion in 'Developer Support' started by Hexdump, May 17, 2018.

  1. Hexdump

    Joined:
    May 15, 2018
    Messages:
    6
    Likes Received:
    0
    Trying to get EmbeddableUI to work, it's having trouble issues finding my resources.

    Here's the error message:

    Code (Text):
    1.  
    2. javafx.fxml.LoadException:
    3. unknown path
    4.  
    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.hexdump.bots.bot.ExampleBot.botInterfaceProperty(ExampleBot.java:44)
    9.    at java.util.concurrent.FutureTask.run(Unknown Source)
    10.    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    11.    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    12.    at java.lang.Thread.run(Unknown Source)
    13. Caused by: java.lang.NullPointerException
    14.    at com.hexdump.bots.bot.ExampleBot.initialize(ExampleBot.java:56)
    15.    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
    16.    ... 6 more
    17.  

    Here's my main class:

    Code (Text):
    1.  
    2. public class ExampleBot extends TreeBot implements EmbeddableUI, Initializable {
    3.     private ObjectProperty<Node> botInterface;
    4.     private ImageView img;
    5.  
    6.     public ExampleBot() {
    7.         setEmbeddableUI(this);
    8.     }
    9.  
    10.     @Override
    11.     public void onStart(String... arguments) {
    12.         setLoopDelay(400, 950);
    13.     }
    14.  
    15.     @Override
    16.     public TreeTask createRootTask() {
    17.         return new RootBranch();
    18.     }
    19.  
    20.     @Override
    21.     public ObjectProperty<? extends Node> botInterfaceProperty() {
    22.         if (botInterface == null) {
    23.             FXMLLoader loader = new FXMLLoader();
    24.             loader.setController(this);
    25.             try {
    26.                 Node node = loader.load(Resources.getAsStream("com/hexdump/bots/bot/ExampleXFML.fxml"));
    27.                 botInterface = new SimpleObjectProperty<>(node);
    28.             } catch (IOException e) {
    29.                 e.printStackTrace();
    30.             }
    31.  
    32.         }
    33.         return botInterface;
    34.     }
    35.  
    36.     @Override
    37.     public void initialize(URL location, ResourceBundle resources) {
    38.         img.setImage(new Image(Resources.getAsStream("com/hexdump/bots/bot/img.jpg")));
    39.     }
    40. }

    And here's a picture of my file tree:

    [​IMG]
     
  2. Wet Rag

    Wet Rag easily triggered ✌

    Joined:
    Dec 31, 2015
    Messages:
    4,457
    Likes Received:
    1,695

Share This Page

Loading...