java - JavaFX: ListView not displaying in GUI -


my problem listview not showing on gui, have added placeholder test , show placeholder text other cannot add list.

my aim have list of clients accounts, have included account class, want display accounts id's in listview.

for reason not work, have tried inputting random data see if thats issue still not luck.

i have static set called allaccounts in main.class file.

any appreciated, have searched near , far , since new struggle understand why not working.

controller.class

public class controller implements initializable{      @fxml     private tableview<?> tableview;     @fxml     private tablecolumn<?, ?> tableaccount;     @fxml     private tablecolumn<?, ?> tabledate;     @fxml     private tablecolumn<?, ?> tabletime;     @fxml     private tablecolumn<?, ?> tabletotal;     @fxml     private tablecolumn<?, ?> tablenotes;     @fxml     private listview<string> list;     @fxml     private textarea invoiceview;     @fxml     private textfield amountfield;     @fxml     private button addamount;     @fxml     private button newinvoice;     @fxml     private button saveinvoice;     @fxml     private button deleteinvoice;     @fxml     private label messagebar;      @override     public void initialize(url location, resourcebundle resources) {         //list.setplaceholder(new label("no content in list"));         observablelist<string> names = fxcollections.observablearraylist(                 "julia", "ian", "sue", "matthew", "hannah", "stephan", "denise");         list = new listview<>();         list.setitems(names);          //tableview = new tableview<>(names);      }      @fxml     public void newinvoicefired() {         system.out.println("new invoice button has been clicked");     }      @fxml     public void deleteinvoicefired() {         system.out.println("delete invoice button has been clicked");      }     @fxml     public void saveinvoicefired() {         system.out.println("save invoice button has been clicked");      }      public void setaccountslist(){          (account account : main.getallaccounts()){          }      }  } 

gui.fxml

<?xml version="1.0" encoding="utf-8"?>  <?import javafx.scene.control.button?> <?import javafx.scene.control.label?> <?import javafx.scene.control.listview?> <?import javafx.scene.control.splitpane?> <?import javafx.scene.control.tablecolumn?> <?import javafx.scene.control.tableview?> <?import javafx.scene.control.textarea?> <?import javafx.scene.control.textfield?> <?import javafx.scene.image.image?> <?import javafx.scene.image.imageview?> <?import javafx.scene.layout.anchorpane?> <?import javafx.scene.layout.hbox?>  <anchorpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="477.0" prefwidth="641.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller">    <children>       <splitpane dividerpositions="0.24249999999999972" layouty="50.0" prefheight="427.0" prefwidth="641.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="50.0">         <items>           <anchorpane minheight="0.0" minwidth="0.0" prefheight="160.0" prefwidth="100.0">                <children>                   <listview fx:id="list" layoutx="-24.0" layouty="62.0" prefheight="425.0" prefwidth="151.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0" />                </children>             </anchorpane>           <anchorpane minheight="0.0" minwidth="0.0" prefheight="445.0" prefwidth="411.0">                <children>                   <splitpane dividerpositions="0.30023640661938533" layoutx="143.0" layouty="123.0" orientation="vertical" prefheight="445.0" prefwidth="480.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0">                     <items>                       <anchorpane minheight="0.0" minwidth="0.0" prefheight="100.0" prefwidth="160.0">                            <children>                               <tableview layoutx="128.0" layouty="45.0" prefheight="208.0" prefwidth="478.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0">                                 <columns>                                     <tablecolumn fx:id="tableaccount" prefwidth="75.0" text="account" />                                   <tablecolumn fx:id="tabledate" prefwidth="75.0" text="date" />                                   <tablecolumn fx:id="tabletime" prefwidth="75.0" text="time" />                                     <tablecolumn fx:id="tabletotal" prefwidth="75.0" text="amount" />                                     <tablecolumn fx:id="tablenotes" prefwidth="75.0" text="notes" />                                 </columns>                               </tableview>                            </children>                         </anchorpane>                       <anchorpane minheight="0.0" minwidth="0.0" prefheight="286.0" prefwidth="478.0">                            <children>                               <splitpane dividerpositions="0.4474789915966387" layoutx="168.0" layouty="48.0" prefheight="292.0" prefwidth="478.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0">                                 <items>                                   <anchorpane minheight="0.0" minwidth="0.0" prefheight="160.0" prefwidth="100.0">                                        <children>                                           <textarea fx:id="invoiceview" layoutx="5.0" layouty="14.0" prefheight="290.0" prefwidth="209.0" anchorpane.bottomanchor="0.0" anchorpane.leftanchor="0.0" anchorpane.rightanchor="0.0" anchorpane.topanchor="0.0" />                                        </children>                                     </anchorpane>                                   <anchorpane minheight="0.0" minwidth="0.0" prefheight="160.0" prefwidth="100.0">                                        <children>                                           <textfield fx:id="amountfield" layoutx="82.0" layouty="86.0" prefheight="27.0" prefwidth="104.0" prompttext="0.00" />                                           <button fx:id="addamount" layoutx="195.0" layouty="86.0" mnemonicparsing="false" text="add" />                                           <label layoutx="14.0" layouty="91.0" text="amount: : " />                                        </children>                                     </anchorpane>                                 </items>                               </splitpane>                            </children>                         </anchorpane>                     </items>                   </splitpane>                </children>             </anchorpane>         </items>       </splitpane>       <imageview fitheight="150.0" fitwidth="200.0" layoutx="14.0" layouty="11.0" pickonbounds="true" preserveratio="true">          <image>             <image url="@icon/logo.png" />          </image>       </imageview>       <hbox alignment="center_right" layoutx="462.0" layouty="14.0" spacing="15.0" anchorpane.rightanchor="14.0" anchorpane.topanchor="14.0">          <children>             <button fx:id="newinvoice" mnemonicparsing="false" onaction="#newinvoicefired" text="new" />             <button fx:id="saveinvoice" mnemonicparsing="false" onaction="#deleteinvoicefired" text="save" />             <button fx:id="deleteinvoice" mnemonicparsing="false" onaction="#deleteinvoicefired" text="delete" />          </children>       </hbox>    </children> </anchorpane> 

account.class

public class account {     private string id;     private string name;     private string address1;     private string address2;     private string postcode;     private set<invoice> invoicearchive = new hashset<>();      public account(string id, string name, string address1, string address2, string postcode) {         this.id = id;         this.name = name;         this.address1 = address1;         this.address2 = address2;         this.postcode = postcode;         main.addaccount(this);     }      public account(string id, string name, string address1, string postcode) {         this.id = id;         this.name = name;         this.address1 = address1;         this.postcode = postcode;     }      public account(string name, string id) {         this.name = name;         this.id = id;     }      public string getid() {          return id;     }      public void setid(string id) {         this.id = id;     }      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public string getaddress1() {         return address1;     }      public void setaddress1(string address1) {         this.address1 = address1;     }      public string getaddress2() {         return address2;     }      public void setaddress2(string address2) {         this.address2 = address2;     }      public string getpostcode() {         return postcode;     }      public void setpostcode(string postcode) {         this.postcode = postcode;     }      public set<invoice> getinvoicearchive() {         return invoicearchive;     }      public invoice newinvoice(){         invoice = new invoice(this);         invoicearchive.add(i);         return i;     }      @override     public string tostring(){         return this.getid();     } } 

you create new instance of list in controller, though listview initialized in fxml file. add items new instance, 1 not added scenegraph, hence original listview remains empty


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -