• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call a new window from a click of a button on the current window in javafx

 
Kelly klark
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I am pretty new at using javafx, i am not using the javafx scene builder, i am using the java application from netbeans 8.

I have been trying to call another window when a user clicks on a button. so far it is not working, i used the FXMLloader and i realised that it is giving me a nullpointer exception.

below is my code for the two classes




below is the second class i am trying to call

please thank you for any help you can render
 
John Damien Smith
Ranch Hand
Posts: 299
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not using FXML, so you don't need to use an FXMLLoader. Your FXMLLoader gives a null pointer exception because you try to load a Java source file, which won't be visible on the class path for a compiled application. Even if the file was visible, it wouldn't work because FXMLLoader works with FXML, not Java source code.

You need to create a new Stage (which is a type of window).

As an aside, best practice for inline SQL is to use a PreparedStatement rather than appending Strings, otherwise your app is vulnerable to SQL Injection attacks.
 
Kelly klark
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a million for this answer JOHN DAMIEN SMITH.. really appreciated note taken for the prepared statement... thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic