Notes - Part I - Say Hello from Java
Posted
by Silviu Turuga
on Oracle Blogs
See other posts from Oracle Blogs
or by Silviu Turuga
Published on Wed, 5 Dec 2012 21:42:06 +0000
Indexed on
2012/12/05
23:12 UTC
Read the original article
Hit count: 215
/02. JavaFX
I'll call this application Notes….
Part I - Say Hello from Java
- From NetBeans go to Files->New Project
- Chose JavaFX->JavaFX FXML Application
-
- Project Name: Notes
- FXML name: NotesUI
- Check Create Application Class and name it Main
- After this the project is created and you'll see the following structure
- As a best practice I advice you to have your code in your own package instead of the default one.
- right click on Source Packages and chose New->Java Package
- name it something like this: com.turuga.notes and click Next
- after the package is created, select all the 3 files from step #3 and drag them over the new package
- chose Refactor, as this will make sure all the references are correctly moved inside the new package
- now you should have the following structure
- if you'll try to run the project you'll get an error: Unable to find class: Main
- right click on project name Notes and click properties
- go to Run and you'll see Application Class set to Main, but because we have defined our own packages, this location has been change, so click on Browse and the correct one appear: com.turuga.notes.Main
- last modification before running the project is to right click on NotesUI.fxml and chose Edit (if you'll double click it will open in JavaFX Scene Builder)
- look around line 9 and change fx:controller="NotesUIController" to fx:controller="com.turuga.notes.NotesUIController"
- now you are ready to run it and you should see the following
On the next lesson we'll continue to play with NetBeans and start working on the interface of our project
© Oracle Blogs or respective owner