• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 387
30
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a million for this answer JOHN DAMIEN SMITH.. really appreciated note taken for the prepared statement... thanks
reply
    Bookmark Topic Watch Topic
  • New Topic