javafx - Calling Fxml file using Start Method which extends Application Class -


i want make new fxml file has few controls label. when run application times not showing , sometime when form showing label not showing.

i have written following code:

dashboard.fxml:

<?xml version="1.0" encoding="utf-8"?>  <?import javafx.scene.text.*?> <?import java.lang.*?> <?import java.net.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?>  <anchorpane id="anchorpane" prefheight="603.0" prefwidth="1063.0" styleclass="mainfxmlclass" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.dashboard.dashboardcontroller">     <stylesheets>         <url value="@dashboard.css" />     </stylesheets>    <children>       <label fx:id="welcome" layoutx="403.0" layouty="52.0" text="label" />    </children>  </anchorpane> 

dashboardcontroller.java :

import java.net.url; import java.util.resourcebundle; import javafx.fxml.fxml; import javafx.fxml.initializable; import javafx.scene.control.label;  /**  * fxml controller class  *  * @author dell  */ public class dashboardcontroller implements initializable {      /**      * initializes controller class.      */     @fxml     private label welcome;     @override     public void initialize(url url, resourcebundle rb) {         // todo     }      } 

dashrun.java :

package com.dashboard;  import javafx.application.application; import static javafx.application.application.launch; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.scene.control.label; import javafx.scene.image.image; import javafx.stage.stage; import javafx.stage.stagestyle;  public class dashrun extends application{        @override     public void start(stage stage) throws exception {         parent root = fxmlloader.load(getclass().getresource("dashboard.fxml"));         scene scene = new scene(root);           label = new label();         stage.settitle("dash board");         stage.setscene(scene);              stage.show();     }     public static void main(string[] args) {         launch(args);     }  } 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -