• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
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
 
Ranch Hand
Posts: 374
24
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!