user interface - JavaFX tab pane not showing up -
user interface - JavaFX tab pane not showing up -
i'm trying create simple ui using fxml application app send text file application used there. goal first tab in tab pane allow user input own grouping names , add together them list of grouping names they've entered. i'm hoping have user type grouping name textfield, , click add together button, move grouping name textarea goes new line. think i've gotten action handler right can't test because when run programme nil shows up! help appreciated.
the java code:
package pipeline.ui; import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.stage.stage; /** * * @author pat */ public class pipelineui extends application { @override public void start(stage stage) throws exception { parent root = fxmlloader.load(getclass().getresource("pipelineui.fxml")); scene scene = new scene(root, 1000, 1000); stage.settitle("pipeline welcome"); stage.setscene(scene); stage.show(); } /** * @param args command line arguments */ public static void main(string[] args) { launch(args); } }
the controller code:
package pipeline.ui; import java.net.url; import java.util.resourcebundle; import javafx.event.actionevent; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.control.button; import javafx.scene.control.label; import javafx.scene.control.tab; import javafx.scene.control.textarea; import javafx.scene.control.textfield; /** * * @author pat */ public class pipelineuicontroller implements initializable { private label label; @fxml private tab groupstab; @fxml private button addgroup; @fxml private button removegroup; @fxml private button proceedbutton1; @fxml public textarea groupslist; @fxml private textfield groupname; private static final string newline = "\n"; public void handlebuttonaction(actionevent event) { if (groupname.gettext() != "") { string name = groupname.gettext(); groupslist.appendtext(name); groupslist.appendtext(newline); } } @override public void initialize(url url, resourcebundle rb) { // todo } }
the fxml code:
<?xml version="1.0" encoding="utf-8"?> <?import javafx.scene.text.*?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <tabpane maxheight="-infinity" maxwidth="-infinity" minheight="-infinity" minwidth="-infinity" prefheight="1000.0" prefwidth="1000.0" tabclosingpolicy="unavailable" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="pipeline.ui.pipelineuicontroller"> <tabs> <tab fx:id="groupstab" text="experimental groups"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0"> <children> <button fx:id="addgroup" layoutx="253.0" layouty="100.0" mnemonicparsing="false" onmouseclicked="handlebuttonaction" text="add grouping >>" /> <button fx:id="removegroup" layoutx="242.0" layouty="173.0" mnemonicparsing="false" text="<< remove group" /> <button fx:id="proceedbutton1" layoutx="534.0" layouty="332.0" mnemonicparsing="false" text="ok" /> <textarea fx:id="groupslist" layoutx="367.0" layouty="86.0" prefheight="200.0" prefwidth="200.0" /> <textfield fx:id="groupname" layoutx="77.0" layouty="100.0" /> <text layoutx="77.0" layouty="82.0" stroketype="outside" strokewidth="0.0" text="add experimental groups examined:" /> </children></anchorpane> </content> </tab> <tab text="untitled tab 2"> <content> <anchorpane minheight="0.0" minwidth="0.0" prefheight="180.0" prefwidth="200.0" /> </content> </tab> </tabs> </tabpane>
not sure if of necessary if help me here i'd appreciate it. thanks!
this wouldn't run me, because have errors in fxml. handler addgroup
button should "#handlebuttonaction"
(the "#" indicates belongs controller, , script).
additionally, since handler method takes actionevent
it's parameter, should
onaction="#handlebuttonaction"
(not onmouseclicked
).
user-interface javafx fxml
Comments
Post a Comment