Create two separated stage in JavaFX





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I created an application which has to open a window when I press on a determinate button. Now, the first part (where I create the layout with all the buttons/textfields/etc..) works, but when I try to set the action that the button has to do I get a list of error on the Button itself. This is the code of my Button Controller:



public class ButtonController {

@FXML
private Button scrivi;

@FXML
private Button reply;

@FXML
private Button replyall;

@FXML
private Button forward;

private DataModel model;

public void initModel(DataModel model) {
if (this.model != null) {
throw new IllegalStateException("Model can only be initialized once");
}
this.model = model;

scrivi.setOnMouseClicked((event) -> {
try {
FXMLLoader pagina = new FXMLLoader(getClass().getResource("panel.fxml"));
BorderPane root = new BorderPane(pagina.load());
PanelController pc = pagina.getController();
pc.initModel(model);
Scene scene = new Scene(root, 603, 403);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
} catch (IOException e) {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.SEVERE, "Failed to create new Window.", e);
}
});
}


This is the FXML of the Panel I want to create:



    <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="PanelController">
<top>
<AnchorPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<TextField fx:id="dest" layoutX="53.0" layoutY="51.0" />
<TextField fx:id="cc" layoutX="53.0" layoutY="92.0" />
<TextField fx:id="mitt" layoutX="53.0" layoutY="135.0" />
<Label layoutX="29.0" layoutY="56.0" text="A:" />
<Label layoutX="24.0" layoutY="97.0" text="CC:" />
<Label layoutX="25.0" layoutY="140.0" text="Da:" />
<TextField fx:id="obj" layoutX="53.0" layoutY="173.0" />
<Label layoutX="22.0" layoutY="178.0" text="Obj:" />
<Button layoutX="539.0" layoutY="14.0" mnemonicParsing="false" text="Invia" />
</children>
</AnchorPane>
</top>
<bottom>
<TextArea id="testo" prefHeight="182.0" prefWidth="564.0" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>


This is the part (which works) of the first panel of the application:



public class MailBox extends Application {

@Override
public void start(Stage stage) throws Exception {
FXMLLoader listLoader = new FXMLLoader(getClass().getResource("lista.fxml"));
FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menubar.fxml"));
FXMLLoader textareaLoader = new FXMLLoader(getClass().getResource("textarea.fxml"));
FXMLLoader fieldLoader = new FXMLLoader(getClass().getResource("textfield.fxml"));
FXMLLoader buttonLoader = new FXMLLoader(getClass().getResource("button.fxml"));

AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());

ListController listController = listLoader.getController();
MenuBarController menuController = menuLoader.getController();
TextAreaController textareaController = textareaLoader.getController();
TextFieldController fieldController = fieldLoader.getController();
ButtonController buttonController = buttonLoader.getController();

DataModel model = new DataModel();
listController.initModel(model);
menuController.initModel(model);
textareaController.initModel(model);
fieldController.initModel(model);
buttonController.initModel(model);

Scene scene = new Scene(root, 603, 403);
stage.setScene(scene);
stage.show();
}


This is the error I get when I try to execute the program:






Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox












share|improve this question


















  • 1





    Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

    – Sai Dandem
    Nov 21 '18 at 20:43











  • Yep, let us know what is ButtonController.java 47th line.

    – bakcsa83
    Nov 21 '18 at 21:23











  • @bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

    – Samoa Joe
    Nov 22 '18 at 9:49











  • try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

    – Calips
    Nov 22 '18 at 15:03


















0















I created an application which has to open a window when I press on a determinate button. Now, the first part (where I create the layout with all the buttons/textfields/etc..) works, but when I try to set the action that the button has to do I get a list of error on the Button itself. This is the code of my Button Controller:



public class ButtonController {

@FXML
private Button scrivi;

@FXML
private Button reply;

@FXML
private Button replyall;

@FXML
private Button forward;

private DataModel model;

public void initModel(DataModel model) {
if (this.model != null) {
throw new IllegalStateException("Model can only be initialized once");
}
this.model = model;

scrivi.setOnMouseClicked((event) -> {
try {
FXMLLoader pagina = new FXMLLoader(getClass().getResource("panel.fxml"));
BorderPane root = new BorderPane(pagina.load());
PanelController pc = pagina.getController();
pc.initModel(model);
Scene scene = new Scene(root, 603, 403);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
} catch (IOException e) {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.SEVERE, "Failed to create new Window.", e);
}
});
}


This is the FXML of the Panel I want to create:



    <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="PanelController">
<top>
<AnchorPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<TextField fx:id="dest" layoutX="53.0" layoutY="51.0" />
<TextField fx:id="cc" layoutX="53.0" layoutY="92.0" />
<TextField fx:id="mitt" layoutX="53.0" layoutY="135.0" />
<Label layoutX="29.0" layoutY="56.0" text="A:" />
<Label layoutX="24.0" layoutY="97.0" text="CC:" />
<Label layoutX="25.0" layoutY="140.0" text="Da:" />
<TextField fx:id="obj" layoutX="53.0" layoutY="173.0" />
<Label layoutX="22.0" layoutY="178.0" text="Obj:" />
<Button layoutX="539.0" layoutY="14.0" mnemonicParsing="false" text="Invia" />
</children>
</AnchorPane>
</top>
<bottom>
<TextArea id="testo" prefHeight="182.0" prefWidth="564.0" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>


This is the part (which works) of the first panel of the application:



public class MailBox extends Application {

@Override
public void start(Stage stage) throws Exception {
FXMLLoader listLoader = new FXMLLoader(getClass().getResource("lista.fxml"));
FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menubar.fxml"));
FXMLLoader textareaLoader = new FXMLLoader(getClass().getResource("textarea.fxml"));
FXMLLoader fieldLoader = new FXMLLoader(getClass().getResource("textfield.fxml"));
FXMLLoader buttonLoader = new FXMLLoader(getClass().getResource("button.fxml"));

AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());

ListController listController = listLoader.getController();
MenuBarController menuController = menuLoader.getController();
TextAreaController textareaController = textareaLoader.getController();
TextFieldController fieldController = fieldLoader.getController();
ButtonController buttonController = buttonLoader.getController();

DataModel model = new DataModel();
listController.initModel(model);
menuController.initModel(model);
textareaController.initModel(model);
fieldController.initModel(model);
buttonController.initModel(model);

Scene scene = new Scene(root, 603, 403);
stage.setScene(scene);
stage.show();
}


This is the error I get when I try to execute the program:






Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox












share|improve this question


















  • 1





    Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

    – Sai Dandem
    Nov 21 '18 at 20:43











  • Yep, let us know what is ButtonController.java 47th line.

    – bakcsa83
    Nov 21 '18 at 21:23











  • @bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

    – Samoa Joe
    Nov 22 '18 at 9:49











  • try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

    – Calips
    Nov 22 '18 at 15:03














0












0








0








I created an application which has to open a window when I press on a determinate button. Now, the first part (where I create the layout with all the buttons/textfields/etc..) works, but when I try to set the action that the button has to do I get a list of error on the Button itself. This is the code of my Button Controller:



public class ButtonController {

@FXML
private Button scrivi;

@FXML
private Button reply;

@FXML
private Button replyall;

@FXML
private Button forward;

private DataModel model;

public void initModel(DataModel model) {
if (this.model != null) {
throw new IllegalStateException("Model can only be initialized once");
}
this.model = model;

scrivi.setOnMouseClicked((event) -> {
try {
FXMLLoader pagina = new FXMLLoader(getClass().getResource("panel.fxml"));
BorderPane root = new BorderPane(pagina.load());
PanelController pc = pagina.getController();
pc.initModel(model);
Scene scene = new Scene(root, 603, 403);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
} catch (IOException e) {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.SEVERE, "Failed to create new Window.", e);
}
});
}


This is the FXML of the Panel I want to create:



    <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="PanelController">
<top>
<AnchorPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<TextField fx:id="dest" layoutX="53.0" layoutY="51.0" />
<TextField fx:id="cc" layoutX="53.0" layoutY="92.0" />
<TextField fx:id="mitt" layoutX="53.0" layoutY="135.0" />
<Label layoutX="29.0" layoutY="56.0" text="A:" />
<Label layoutX="24.0" layoutY="97.0" text="CC:" />
<Label layoutX="25.0" layoutY="140.0" text="Da:" />
<TextField fx:id="obj" layoutX="53.0" layoutY="173.0" />
<Label layoutX="22.0" layoutY="178.0" text="Obj:" />
<Button layoutX="539.0" layoutY="14.0" mnemonicParsing="false" text="Invia" />
</children>
</AnchorPane>
</top>
<bottom>
<TextArea id="testo" prefHeight="182.0" prefWidth="564.0" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>


This is the part (which works) of the first panel of the application:



public class MailBox extends Application {

@Override
public void start(Stage stage) throws Exception {
FXMLLoader listLoader = new FXMLLoader(getClass().getResource("lista.fxml"));
FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menubar.fxml"));
FXMLLoader textareaLoader = new FXMLLoader(getClass().getResource("textarea.fxml"));
FXMLLoader fieldLoader = new FXMLLoader(getClass().getResource("textfield.fxml"));
FXMLLoader buttonLoader = new FXMLLoader(getClass().getResource("button.fxml"));

AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());

ListController listController = listLoader.getController();
MenuBarController menuController = menuLoader.getController();
TextAreaController textareaController = textareaLoader.getController();
TextFieldController fieldController = fieldLoader.getController();
ButtonController buttonController = buttonLoader.getController();

DataModel model = new DataModel();
listController.initModel(model);
menuController.initModel(model);
textareaController.initModel(model);
fieldController.initModel(model);
buttonController.initModel(model);

Scene scene = new Scene(root, 603, 403);
stage.setScene(scene);
stage.show();
}


This is the error I get when I try to execute the program:






Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox












share|improve this question














I created an application which has to open a window when I press on a determinate button. Now, the first part (where I create the layout with all the buttons/textfields/etc..) works, but when I try to set the action that the button has to do I get a list of error on the Button itself. This is the code of my Button Controller:



public class ButtonController {

@FXML
private Button scrivi;

@FXML
private Button reply;

@FXML
private Button replyall;

@FXML
private Button forward;

private DataModel model;

public void initModel(DataModel model) {
if (this.model != null) {
throw new IllegalStateException("Model can only be initialized once");
}
this.model = model;

scrivi.setOnMouseClicked((event) -> {
try {
FXMLLoader pagina = new FXMLLoader(getClass().getResource("panel.fxml"));
BorderPane root = new BorderPane(pagina.load());
PanelController pc = pagina.getController();
pc.initModel(model);
Scene scene = new Scene(root, 603, 403);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
} catch (IOException e) {
Logger logger = Logger.getLogger(getClass().getName());
logger.log(Level.SEVERE, "Failed to create new Window.", e);
}
});
}


This is the FXML of the Panel I want to create:



    <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="PanelController">
<top>
<AnchorPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<TextField fx:id="dest" layoutX="53.0" layoutY="51.0" />
<TextField fx:id="cc" layoutX="53.0" layoutY="92.0" />
<TextField fx:id="mitt" layoutX="53.0" layoutY="135.0" />
<Label layoutX="29.0" layoutY="56.0" text="A:" />
<Label layoutX="24.0" layoutY="97.0" text="CC:" />
<Label layoutX="25.0" layoutY="140.0" text="Da:" />
<TextField fx:id="obj" layoutX="53.0" layoutY="173.0" />
<Label layoutX="22.0" layoutY="178.0" text="Obj:" />
<Button layoutX="539.0" layoutY="14.0" mnemonicParsing="false" text="Invia" />
</children>
</AnchorPane>
</top>
<bottom>
<TextArea id="testo" prefHeight="182.0" prefWidth="564.0" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>


This is the part (which works) of the first panel of the application:



public class MailBox extends Application {

@Override
public void start(Stage stage) throws Exception {
FXMLLoader listLoader = new FXMLLoader(getClass().getResource("lista.fxml"));
FXMLLoader menuLoader = new FXMLLoader(getClass().getResource("menubar.fxml"));
FXMLLoader textareaLoader = new FXMLLoader(getClass().getResource("textarea.fxml"));
FXMLLoader fieldLoader = new FXMLLoader(getClass().getResource("textfield.fxml"));
FXMLLoader buttonLoader = new FXMLLoader(getClass().getResource("button.fxml"));

AnchorPane root = new AnchorPane(listLoader.load(), textareaLoader.load(), fieldLoader.load(), menuLoader.load(), buttonLoader.load());

ListController listController = listLoader.getController();
MenuBarController menuController = menuLoader.getController();
TextAreaController textareaController = textareaLoader.getController();
TextFieldController fieldController = fieldLoader.getController();
ButtonController buttonController = buttonLoader.getController();

DataModel model = new DataModel();
listController.initModel(model);
menuController.initModel(model);
textareaController.initModel(model);
fieldController.initModel(model);
buttonController.initModel(model);

Scene scene = new Scene(root, 603, 403);
stage.setScene(scene);
stage.show();
}


This is the error I get when I try to execute the program:






Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox








Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox





Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at mailbox.ButtonController.initModel(ButtonController.java:47)
at mailbox.MailBox.start(MailBox.java:43)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Exception running application mailbox.MailBox






java button javafx scene stage






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 20:21









Samoa JoeSamoa Joe

206




206








  • 1





    Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

    – Sai Dandem
    Nov 21 '18 at 20:43











  • Yep, let us know what is ButtonController.java 47th line.

    – bakcsa83
    Nov 21 '18 at 21:23











  • @bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

    – Samoa Joe
    Nov 22 '18 at 9:49











  • try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

    – Calips
    Nov 22 '18 at 15:03














  • 1





    Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

    – Sai Dandem
    Nov 21 '18 at 20:43











  • Yep, let us know what is ButtonController.java 47th line.

    – bakcsa83
    Nov 21 '18 at 21:23











  • @bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

    – Samoa Joe
    Nov 22 '18 at 9:49











  • try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

    – Calips
    Nov 22 '18 at 15:03








1




1





Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

– Sai Dandem
Nov 21 '18 at 20:43





Can you let us know where the NPE is occurring. Cannot figure out the exact line by line numbers in error log.

– Sai Dandem
Nov 21 '18 at 20:43













Yep, let us know what is ButtonController.java 47th line.

– bakcsa83
Nov 21 '18 at 21:23





Yep, let us know what is ButtonController.java 47th line.

– bakcsa83
Nov 21 '18 at 21:23













@bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

– Samoa Joe
Nov 22 '18 at 9:49





@bakcsa83 The line corresponds at scrivi.setOnMouseClicked((event) -> {

– Samoa Joe
Nov 22 '18 at 9:49













try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

– Calips
Nov 22 '18 at 15:03





try this instead : scrivi.setOnAction(new EventHandler<ActionEvent>() {......});

– Calips
Nov 22 '18 at 15:03












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419926%2fcreate-two-separated-stage-in-javafx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419926%2fcreate-two-separated-stage-in-javafx%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)