---main class ---
package javafxtemplate1;
//Grid_VBOx_Thread
import java.io.IOException;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
public class JavaFXTemplate1 extends Application {
//String path ="C:/NetBean_Examples/JavaCore/JavaFXTemplate1/JavaFXMLDoc1.fxml";
@Override
public void start(Stage primaryStage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("JavaFXMLDoc1.fxml"));
//Scene scene = new Scene(root);
//Group root = new Group();
Scene scene = new Scene(root, 450,300);
primaryStage.setScene(scene);
primaryStage.setTitle("FXML AnchorPane::List , ListView::Label,
Button");
primaryStage.show();
}
//
//
public static void main(String[] args) {
Application.launch(args);
}
}
------JavaFXMLDoc1-------
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.net.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.Label?>
<AnchorPane id="AnchorPane" prefHeight="304.0" prefWidth="408.0"
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="javafxtemplate1.JavaFXMLDoc1Controller">
<stylesheets>
<URL value="@javafxmldoc1.css" />
</stylesheets>
<children>
<Button fx:id="button" layoutX="24.0" layoutY="14.0" onAction="#startTask"
text="Click Me!" />
<Label fx:id="label1" layoutX="139.0" layoutY="18.0" minHeight="16"
minWidth="69" />
<ListView fx:id="lvwList1" layoutX="128.0" layoutY="71.0" prefHeight="141.0"
prefWidth="152.0" />
<Button layoutX="31.0" layoutY="227.0" mnemonicParsing="false"
onAction="#endTask" text="Exit" />
</children>
</AnchorPane>
----JavaFXMLDoc1Controller ---
package javafxtemplate1;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;
/**
* FXML Controller class
*
* @author Manas9
*/
public class JavaFXMLDoc1Controller implements Initializable {
/**
* Initializes the controller class.
*/
@FXML
private Label label1, label2;
@FXML
ListView lvwList1 = new ListView();
@FXML
ObservableList<String> oString1;
@FXML
private void startTask(ActionEvent event) {
List list1 = new ArrayList();
label1.setText(" started");
list1.add( "str1");
list1.add("str2");
list1.add( "str3");
ObservableList<String> items
=FXCollections.observableArrayList(list1);
lvwList1.setItems(items);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
//label2.setText("Initialized ");
System.out.println("initialized!");
}
@FXML
private void endTask(ActionEvent event) {
//System.out.println("You clicked me!");
Platform.exit();
}
}