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

Filed under:
Sometimes we need to take small notes to remember things, one way to do this is to use stick notes and have them all around our desktop. But what happening if you have a lot of notes and a small office? You'll need a piece of software that will sort things for you and also it will provide you a quick way to retrieve the notes when need. Did I mention that this will keep your desktop clean and also will reduce paper waste?

During the next days we'll gonna create an application that will let you manage your notes, put them in different categories etc. I'll show you step by step what do you need to do and finally you'll have the application run on multiple systems, such as Mac, Windows, Linux, etc.

The only pre-requisition for this lesson is to have JDK 7 with JavaFX installed and an IDE, preferably NetBeans.

I'll call this application Notes….

Part I - Say Hello from Java 

  1. From NetBeans go to Files->New Project

  2. Chose JavaFX->JavaFX FXML Application
    1. Project Name: Notes
    2. FXML name: NotesUI
    3. Check Create Application Class and name it Main

  3. After this the project is created and you'll see the following structure

  4. As a best practice I advice you to have your code in your own package instead of the default one.
    1. right click on Source Packages and chose New->Java Package
    2. name it something like this: com.turuga.notes and click Next
    3. after the package is created, select all the 3 files from step #3 and drag them over the new package
    4. chose Refactor, as this will make sure all the references are correctly moved inside the new package
    5. now you should have the following structure
    6. if you'll try to run the project you'll get an error: Unable to find class: Main
    7. right click on project name Notes and click properties
    8. 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
    9. 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)
    10. look around line 9 and change fx:controller="NotesUIController" to fx:controller="com.turuga.notes.NotesUIController"
    11. 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

Related posts about /02. JavaFX