I am building a JavaFX application through E(fx)clipse and Java Scene Builder.
The basic functionality is a login window. Once logged in, new window opens and the login window disapears. Right now it's just at the prototype stage.
When running out of ecplise, the functionality I want is all there. Login window shows up on start (code looking as such)
@Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("view/login.fxml"), ResourceBundle.getBundle("ca.sportstats.resources.labels"));
primaryStage.setTitle("SportStats Live Update Tool : Login");
primaryStage.setScene(new Scene(root, 450, 300));
primaryStage.show();
} catch (IOException e) {
//Change this to open a small popup window.
System.out.println("Could not deploy");
}
}
public static void main(String[] args) {
launch(args);
}
There is one button on this window that simply opens another (the login logic will come later and not an issue here).
btnLogin.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
//TODO: Login logic.
//On success allow to open the tool (aka main window);
Parent root;
try {
root = FXMLLoader.load(getClass().getResource("../view/selector.fxml"), resources);
Stage stage = new Stage();
stage.setTitle("Selector");
stage.setScene(new Scene(root, 450, 450));
stage.show();
//hide this current window
((Node)(event.getSource())).getScene().getWindow().hide();
} catch (IOException e) {
e.printStackTrace();
}
}
});
This works no problem in Ecplise. BUT! When I build this (in the fashion described on the e(fx)clipse tutorials I get an executable jar, but only get the login window. When I click my button the 2nd window doesn't show up.