This is my main class
package FSM;
import java.io.IOException;
import FSM.view.PersonEditDetailsControler;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import FSM.model.Person;
import FSM.view.PersonOverviewController;
public class Main extends Application {
private Stage primaryStage;
private BorderPane rootLayout;
private ObservableList<Person> personData= FXCollections.observableArrayList();
public Main() {
// Add some sample data
System.out.println("1 prit");
personData.add(new Person("Hans", "Muster"));
personData.add(new Person("Ruth", "Mueller"));
personData.add(new Person("Heinz", "Kurz"));
personData.add(new Person("Cornelia", "Meier"));
personData.add(new Person("Werner", "Meyer"));
personData.add(new Person("Lydia", "Kunz"));
personData.add(new Person("Anna", "Best"));
personData.add(new Person("Stefan", "Meier"));
personData.add(new Person("Martin", "Mueller"));
}
public ObservableList<Person> getPersonData() {
return personData;
}
@Override
public void start(Stage primaryStage) throws Exception{
System.out.println("2 print");
this.primaryStage = primaryStage;
primaryStage.setTitle("AddressApp");
initRootLayout();
showPersonOverview();
}
public void initRootLayout() {
try {
// Load root layout from fxml file.
System.out.println("rootLayout");
FXMLLoader loader = new FXMLLoader();
System.out.println("geting rootlayout");
loader.setLocation(Main.class.getResource("/FSM/view/RootLayout.fxml"));
System.out.println("setting borderPane");
rootLayout = (BorderPane) loader.load();
System.out.println("loaded");
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
System.out.println("new scene 1");
primaryStage.setScene(scene);
System.out.println("set scene");
primaryStage.show();
System.out.println("rootLayout End 1");
} catch (IOException e) {
System.out.println("rootLayout Exception");
e.printStackTrace();
}
}
public void showPersonOverview() {
try {
System.out.println("3 Print");
// Load person overview.
FXMLLoader loader = new FXMLLoader();
System.out.println("getting Resouurce");
loader.setLocation(Main.class.getResource("/FSM/view/PersonOverview.fxml"));
System.out.println("got Resouurce");
AnchorPane personOverview = (AnchorPane) loader.load();
System.out.println("loading Anchor");
// Set person overview into the center of root layout.
rootLayout.setCenter(personOverview);
System.out.println("setting person overview");
PersonOverviewController controller = loader.getController();
controller.setMain(this);
} catch (IOException e) {
e.printStackTrace();
System.out.println("3 Print exception");
}
}
public boolean showPersonEditDialog(Person person){
try {
System.out.println("4 print");
FXMLLoader loader=new FXMLLoader();
loader.setLocation(Main.class.getResource("/FSM/view/PersonEditDetails.fxml"));
AnchorPane anchorPane=(AnchorPane)loader.load();
rootLayout.setCenter(anchorPane);
Stage dialogStage = new Stage();
dialogStage.setTitle("Edit Person");
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(primaryStage);
Scene scene = new Scene(anchorPane);
dialogStage.setScene(scene);
PersonEditDetailsControler controllerr = loader.getController();
controllerr.setDialogStage(dialogStage);
controllerr.setPerson(person);
dialogStage.showAndWait();
return controllerr.isOKClicked();
}catch (Exception e){
e.printStackTrace();
System.out.println("4th print");
return false;
}
}
public Stage getPrimaryStage() {
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
}
And this is PersonOverViewController class
package FSM.view;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import FSM.model.Person;
import FSM.Main;
import javafx.scene.web.WebEvent;
import java.lang.Object.*;
/**
* Created by mfaseem on 6/9/2015.
*/
public class PersonOverviewController {
@FXML
private TableView<Person> PersonTable;
@FXML
private TableColumn<Person,String> fnameColumn;
@FXML
private TableColumn<Person, String> lnameColumn;
@FXML
private Label fnameLabel;
@FXML
private Label lnameLabel;
@FXML
private Label streetLabel;
@FXML
private Label postelCodeLabel;
@FXML
private Label CityLabel;
@FXML
private Label dobLabel;
private Main main;
public PersonOverviewController(){
}
@FXML
private void initialize(){
fnameColumn.setCellValueFactory(CellData -> CellData.getValue().fnameProperties());
lnameColumn.setCellValueFactory(CellData -> CellData.getValue().lnameProperties());
showPersonDetails(null);
PersonTable.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) ->showPersonDetails(newValue));
}
@FXML
private void deleteHandler(){
int selectedIndex=PersonTable.getSelectionModel().getSelectedIndex();
if(selectedIndex>=0){
PersonTable.getItems().remove(selectedIndex);
}else {
// ALERT alert = new Alert(AlertType.WARNING);
//alert.initOwner(mainApp.getPrimaryStage());
// alert.setTitle("No Selection");
// alert.setHeaderText("No Person Selected");
// alert.setContentText("Please select a person in the table.");
// alert.showAndWait();
}
}
@FXML
private void handleNewPerson() {
Person tempPerson = new Person();
boolean okClicked = main.showPersonEditDialog(tempPerson);
if (okClicked) {
main.getPersonData().add(tempPerson);
}
}
@FXML
private void handleEditPerson() {
Person selectedPerson = PersonTable.getSelectionModel().getSelectedItem();
if (selectedPerson != null) {
boolean okClicked = main.showPersonEditDialog(selectedPerson);
if (okClicked) {
showPersonDetails(selectedPerson);
}
} else {
/* Nothing selected.
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Person Selected");
alert.setContentText("Please select a person in the table.");
alert.showAndWait();
*/
}
}
public void setMain(Main main){
this.main=main;
PersonTable.setItems(main.getPersonData());
}
private void showPersonDetails(Person person){
if(person !=null){
fnameLabel.setText(person.getFname());
lnameLabel.setText(person.getLname());
streetLabel.setText(person.getStreet());
CityLabel.setText(person.getCity());
dobLabel.setText(person.getBirthDate().toString());
postelCodeLabel.setText(String.valueOf(person.getPostalCode()));
}else{
fnameLabel.setText("");
lnameLabel.setText("");
streetLabel.setText("");
CityLabel.setText("");
dobLabel.setText("");
postelCodeLabel.setText("");
}
}
}
And the out put is
Device "Intel(R) Q45/Q43 Express Chipset" (\\.\DISPLAY1) initialization failed :
WARNING: bad driver version detected, device disabled. Please update your driver to at least version 8.15.10.2302
1 prit
2 print
rootLayout
geting rootlayout
setting borderPane
loaded
new scene 1
set scene
javafx.fxml.LoadException: /C:/Users/mfaseem/IdeaProjects/AddressApp/out/production/AddressApp/FSM/view/PersonOverview.fxml:7
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2595)
at javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:104)
Can any one help me thanks in advance