java - how to determine Parent Class for my javafx vbox -
i novice javafx, , working on javafx application. error got unable fetch child node fxml file, fxml file this
<children> <vbox fx:id="sidemenuvbox" alignment="top_center" maxheight="1.7976931348623157e308" maxwidth="1.7976931348623157e308" minheight="600.0" minwidth="125.0"> <children> <button fx:id="headingbutton" maxwidth="1.7976931348623157e308" onaction="#helpbuttononaction" text="masters" /> <button fx:id="opencompanybutton" maxwidth="1.7976931348623157e308" onaction="#opencompanybuttononaction" text="open company" textalignment="center" wraptext="true" /> <button fx:id="newcompanybutton" maxwidth="1.7976931348623157e308" onaction="#newcompanybuttononaction" text="new company" textalignment="center" wraptext="true" /> <button fx:id="closecompanybutton" maxwidth="1.7976931348623157e308" onaction="#closecompanybuttononaction" text="close company" textalignment="center" wraptext="true" /> <button fx:id="chartofaccountsbutton" maxwidth="1.7976931348623157e308" onaction="#chartofaccountsbuttononaction" text="chart of accounts" textalignment="center" wraptext="true" /> <button fx:id="newuserbutton" maxwidth="1.7976931348623157e308" onaction="#newuserbuttononaction" text="new user" textalignment="center" wraptext="true" /> <button fx:id="usersetupbutton" maxwidth="1.7976931348623157e308" onaction="#usersetupbuttononaction" text="user setup" textalignment="center" wraptext="true" /> <button fx:id="unitmasterbutton" maxwidth="1.7976931348623157e308" onaction="#unitmasterbuttononaction" text="unit master" textalignment="center" wraptext="true" /> <button fx:id="itemmasterbutton" maxwidth="1.7976931348623157e308" onaction="#itemmasterbuttononaction" text="item master" textalignment="center" wraptext="true" /> <button fx:id="narrationsetupbutton" maxwidth="1.7976931348623157e308" onaction="#narrationsetupbuttononaction" text="narration setup" textalignment="center" wraptext="true" /> <button fx:id="miscellaneoussetupbutton" maxwidth="1.7976931348623157e308" onaction="#miscellaneoussetupbuttononaction" text="miscellaneous setup" textalignment="center" wraptext="true" /> <button fx:id="numberingsetupbutton" maxwidth="1.7976931348623157e308" onaction="#numberingsetupbuttononaction" text="numbering setup" textalignment="center" wraptext="true" /> <button fx:id="sundrysetupbutton" maxwidth="1.7976931348623157e308" onaction="#sundrysetupbuttononaction" text="sundry setup" textalignment="center" wraptext="true" /> <button fx:id="inventoryflowbutton" maxwidth="1.7976931348623157e308" onaction="#inventoryflowbuttononaction" text="inventory flow" textalignment="center" wraptext="true" /> <button fx:id="challantypebutton" maxwidth="1.7976931348623157e308" onaction="#challantypebuttononaction" text="challan type" textalignment="center" wraptext="true" /> <button fx:id="mergeledgersbutton" maxwidth="1.7976931348623157e308" onaction="#mergeledgersbuttononaction" text="merge ledgers" textalignment="center" wraptext="true" /> <button fx:id="transferopeningbalancebutton" maxwidth="1.7976931348623157e308" onaction="#transferopeningbalancebuttononaction" text="transfer opening balance" textalignment="center" wraptext="true" /> <button fx:id="backuprestorebutton" maxwidth="1.7976931348623157e308" onaction="#backuprestorebuttononaction" text="back & restore" textalignment="center" wraptext="true" /> <button fx:id="helpbutton" maxwidth="1.7976931348623157e308" onaction="#helpbuttononaction" text="help" textalignment="center" wraptext="true" /> </children> </vbox> </children> </anchorpane>
i getting vbox,but not other button. here corresponding controller code. public class modifymenu implements initializable{
@fxml private label titleofpage; @fxml private combobox<string> combo; @fxml private vbox vbox; @fxml private anchorpane anchor; private list<string> masterslist; private list<string> addressbooklist; private list<string> voucherslist; private list<string> salespurchaselist; private list<string> financialregisterslist; private list<string> inventoryregisterslist; private list<string> finalreportslist; private list<string> misreportslist; @fxml private anchorpane content; public void comboonaction() { string selecteditem=this.combo.getselectionmodel().getselecteditem(); list<string> resultantlist; if(selecteditem.equals("masters")) { resultantlist=this.masterslist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("address book")) { resultantlist=this.addressbooklist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("vouchers")) { resultantlist=this.voucherslist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("sales purchase")) { resultantlist=this.salespurchaselist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("financial registers")) { resultantlist=this.financialregisterslist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("inventory registors")) { resultantlist=this.inventoryregisterslist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("final reports")) { resultantlist=this.finalreportslist; this.vbox.getchildren().clear(); show(resultantlist); } else if(selecteditem.equals("mis reports")) { resultantlist=this.misreportslist; this.vbox.getchildren().clear(); show(resultantlist); } } public void show(list<string> menutypeinstring) { observablelist menuobservalearraylist= fxcollections.observablearraylist(menutypeinstring); for(int i=0;i<menuobservalearraylist.size();i++) { hbox hbox=new hbox(); label dynamiclistlabel=new label(); // dynamiclistlabel.setmaxsize(100,10); dynamiclistlabel.settext(menuobservalearraylist.get(i).tostring()); textfield newnametextfield=new textfield(); // newnametextfield.setmaxsize(100,10); button makechangebutton=new button(); makechangebutton.settext("change name"); makechangebutton.setonaction(new eventhandler<actionevent>() { @override public void handle(actionevent event) { string buttonname=dynamiclistlabel.tostring(); string inputbuttonname = newnametextfield.gettext(); system.out.println(getclass().getresource("")); try { content=fxmlloader.load(getclass().getresource ("/com/openlx/kalculate/views/masters/sidemenu.fxml")); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } // anchorpane childholder; // childholder.getchildren().addall(content); //content.getchildrenunmodifiable().listiterator(i).tostring(); system.out.println(content.getchildren().tostring()); // ((pane) content.getchildren()).getchildren(); system.out.println(((pane) content.getchildren()).getchildren().tostring()); /* content.getchildren().clear(); content.getchildren().addall(); button btn=(button) content.lookup(buttonname); hbox.getchildren().add(dynamiclistlabel); hbox.getchildren().add(newnametextfield); hbox.getchildren().add(makechangebutton); hbox.getchildren().add(btn); */ } }); hbox.getchildren().add(dynamiclistlabel); hbox.getchildren().add(newnametextfield); hbox.getchildren().add(makechangebutton); vbox.getchildren().add(hbox); if(newnametextfield.gettext()!=null) { } } } @override public void initialize(url location, resourcebundle resources) { // todo auto-generated method stub list<string> mainlist=new arraylist<string>(); mainlist.add("masters"); mainlist.add("address book"); mainlist.add("vouchers"); mainlist.add("sales purchase"); mainlist.add("financial registers"); mainlist.add("inventory registers"); mainlist.add("final reports"); mainlist.add("mis reports"); observablelist menuobservalearraylist= fxcollections.observablearraylist(mainlist); combo.setitems(menuobservalearraylist); masterslist=new arraylist<string>(); masterslist.add("open company"); masterslist.add("new company"); masterslist.add("close company"); masterslist.add("charts of accounts"); masterslist.add("new user"); masterslist.add("user setup"); masterslist.add("unit master"); masterslist.add("item master"); masterslist.add("narration setup"); masterslist.add("miscellaneous setup"); masterslist.add("numbering setup"); masterslist.add("sundry setup"); masterslist.add("inventory flow"); masterslist.add("challan type"); masterslist.add("merge ledgers"); masterslist.add("transfering opening balance"); masterslist.add("back & restore"); masterslist.add("help"); addressbooklist=new arraylist<string>(); addressbooklist.add("show address book"); addressbooklist.add("supplier entry"); addressbooklist.add("customer entry"); addressbooklist.add("help"); voucherslist=new arraylist<string>(); voucherslist.add("cash reciept"); voucherslist.add("cash payement"); voucherslist.add("bank reciept"); voucherslist.add("bank payement"); voucherslist.add("journal voucher"); voucherslist.add("journal sales"); voucherslist.add("journal purchase"); voucherslist.add("debit note"); voucherslist.add("credit note"); voucherslist.add("contra entry"); voucherslist.add("help"); salespurchaselist=new arraylist<string>(); salespurchaselist.add("quotation"); salespurchaselist.add("order acknowledgement"); salespurchaselist.add("challan cum sales invoice"); salespurchaselist.add("challan"); salespurchaselist.add("sales invoice"); salespurchaselist.add("sales return"); salespurchaselist.add("enquiry"); salespurchaselist.add("purchase order"); salespurchaselist.add("purchase invoice"); salespurchaselist.add("purchase return"); salespurchaselist.add("grn cum purchase invoice"); salespurchaselist.add("goods reciept note"); salespurchaselist.add("process existing voucher"); salespurchaselist.add("stock adjustment voucher(add)"); salespurchaselist.add("stock adjustment voucher(deduct)"); salespurchaselist.add("help"); financialregisterslist=new arraylist<string>(); financialregisterslist.add("cash book"); financialregisterslist.add("cash reciept book"); financialregisterslist.add("cash payement book"); financialregisterslist.add("bank book"); financialregisterslist.add("bank payement book"); financialregisterslist.add("bank reciept book"); financialregisterslist.add("day book"); financialregisterslist.add("ledger"); financialregisterslist.add("journal book"); financialregisterslist.add("debit note book"); financialregisterslist.add("credit note book"); financialregisterslist.add("cheque book"); financialregisterslist.add("customer book"); financialregisterslist.add("supplier book"); financialregisterslist.add("help"); inventoryregisterslist=new arraylist<string>(); inventoryregisterslist.add("quotation registers"); inventoryregisterslist.add("order acknowledgement registers"); inventoryregisterslist.add("challan registers"); inventoryregisterslist.add("invoice registers"); inventoryregisterslist.add("sales return registers"); inventoryregisterslist.add("sales registers"); inventoryregisterslist.add("sales summary"); inventoryregisterslist.add("enquiry registers"); inventoryregisterslist.add("purchase order registers"); inventoryregisterslist.add("purchase invoice registers"); inventoryregisterslist.add("purchase return registers"); inventoryregisterslist.add("goods reciept note registers"); inventoryregisterslist.add("purchase registers"); inventoryregisterslist.add("purchase summary"); inventoryregisterslist.add("stock registers"); inventoryregisterslist.add("stock movement"); inventoryregisterslist.add("stock adjustment details"); inventoryregisterslist.add("custom stock balance"); inventoryregisterslist.add("help"); finalreportslist=new arraylist<string>(); finalreportslist.add("trial balance"); finalreportslist.add("income , expenditure a/c"); finalreportslist.add("profit , loss a/c"); finalreportslist.add("balance sheet a/c"); finalreportslist.add("help"); misreportslist=new arraylist<string>(); misreportslist.add("group summary"); misreportslist.add("statement of debtors ageing"); misreportslist.add("statement of creditors ageing"); misreportslist.add("sundry ledgers"); misreportslist.add("account status confirmation"); misreportslist.add("payement reminders"); misreportslist.add("negative cash warning"); misreportslist.add("depraction statement"); misreportslist.add("item ladger"); misreportslist.add("re-order level report"); misreportslist.add("rate list"); misreportslist.add("customer ledger"); misreportslist.add("supplier ledger"); misreportslist.add("bank reconciliation"); misreportslist.add("help"); } }
the error coming in basicaaly part,
@override public void handle(actionevent event) { string buttonname=dynamiclistlabel.tostring(); string inputbuttonname = newnametextfield.gettext(); system.out.println(getclass().getresource("")); try { content=fxmlloader.load(getclass().getresource ("/com/openlx/kalculate/views/masters/sidemenu.fxml")); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } // anchorpane childholder; // childholder.getchildren().addall(content); //content.getchildrenunmodifiable().listiterator(i).tostring(); system.out.println(content.getchildren().tostring()); // ((pane) content.getchildren()).getchildren(); system.out.println(((pane) content.getchildren()).getchildren().tostring()); /* content.getchildren().clear(); content.getchildren().addall(); button btn=(button) content.lookup(buttonname); hbox.getchildren().add(dynamiclistlabel); hbox.getchildren().add(newnametextfield); hbox.getchildren().add(makechangebutton); hbox.getchildren().add(btn); */ } }); hbox.getchildren().add(dynamiclistlabel); hbox.getchildren().add(newnametextfield); hbox.getchildren().add(makechangebutton); vbox.getchildren().add(hbox);
i tried many things says parent$2 can't cast javafx.scene.(any).
your content
variable anchorpane
, line
((pane) content.getchildren()).getchildren();
is wrong, since content.getchildren()
returns child list (observablelist<node>
) , cannot cast pane
.
the vbox fx:id="sidemenuvbox" child of anchorpane. can as
vbox vb = (vbox) content.getchildren().get(0);
then can button children of vbox by
vb.getchildren();
however, controls in fxml file have fx:id
attribute defined. can directly inject , access them these ids. more info, research on fx:id used for.
Comments
Post a Comment