Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaFX - Wrapping FXML to Java Class Controller
    primarykey
    data
    text
    <p>I have a FXML file that has a TreeView control:</p> <pre><code>&lt;AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="500.0" xmlns:fx="http://javafx.com/fxml" fx:controller="test.MyControllerClass"&gt; &lt;TreeView fx:id="locationTreeView" layoutX="12.0" layoutY="158.0" prefHeight="193.0" prefWidth="471.0" /&gt; </code></pre> <p>Then my Java Class Controller needs to wrap with this TreeView and add TreeItem's dynamically. That's the problem, it isn't loading those TreeItem's. That's the test code below, from my Controller:</p> <pre><code>public class MyControllerClass extends Application { @FXML private TreeView&lt;String&gt; locationTreeView; @Override public void start(Stage stage) throws Exception { stage.initStyle(StageStyle.TRANSPARENT); stage.getIcons().add(new Image(getClass().getResourceAsStream("myIcon.png"))); Parent root = FXMLLoader.load(getClass().getResource("myInterface.fxml")); Scene scene = new Scene(root); stage.setScene(scene); loadTreeItems(); stage.show(); } // Just a simple example that still doesn't works private void loadTreeItems() { try { TreeItem&lt;String&gt; root = new TreeItem&lt;String&gt;("Root Node"); root.setExpanded(true); root.getChildren().addAll( new TreeItem&lt;String&gt;("Item 1"), new TreeItem&lt;String&gt;("Item 2"), new TreeItem&lt;String&gt;("Item 3") ); locationTreeView = new TreeView&lt;String&gt;(root); } catch (Exception exc) { System.out.println("Error: " + exc.getMessage()); } } public static void main(String[] args) { launch(args); } } </code></pre> <p>Any ideas why its not working?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload