java - how to add Array of Node dynamically in FXML -
java - how to add Array of Node dynamically in FXML -
i want add together array of vbox in text , button dynamically through controller
i have controller implementing initializable interface, , overrides intialize() method
controller
package hospitalnavigator;
import java.io.bytearrayinputstream; import java.io.inputstream; import java.net.url; import java.util.resourcebundle; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.geometry.insets; import javafx.scene.control.button; import javafx.scene.image.image; import javafx.scene.image.imageview; import javafx.scene.layout.hbox; import javafx.scene.layout.vbox; import javafx.scene.text.text; public class doctorscontroller implements initializable { public hbox hbox[]; public imageview icon[]; public vbox vbox[]; public text name[]; public text education[]; public button button[]; @fxml public vbox vbox; screenscontroller mycontroller; @override public void initialize(url location, resourcebundle resources) { text test= new text("say"); button button = new button("helo"); hbox[] hbox = new hbox[2]; hbox[0].getchildren().addall(test,button); hbox[1].getchildren().addall(test,button); vbox.getchildren().addall(hbox[0],hbox[1]); } } fxml
<?xml version="1.0" encoding="utf-8"?> <?import javafx.scene.layout.borderpane?> <?scenebuilder-stylesheet application.css?> <?import javafx.scene.layout.vbox?> <borderpane id="bod" fx:controller="hospitalnavigator.doctorscontroller" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <center> <vbox fx:id="vbox" alignment="center" spacing="20"> </vbox> </center> </borderpane>
i believe relevant tutorial: https://blogs.oracle.com/jmxetc/entry/connecting_scenebuilder_edited_fxml_to
this reply shows how vbox without using fx:id fxml attribute: how find element id in javafx?
java javafx
Comments
Post a Comment