Saturday, January 26, 2013

Reminders: a JavaFX and JPA demo application

This time around, I wrote a somewhat more serious demo application, called 'Reminders' (guess what it does). It's cool in oh so many ways:

  • JPA is used for persistence, together with bean validation to check constraints before persisting an entity.
  • FontAwesome is used for its cool icons. They look great and because they are text, you can easily change their size or color.
  • Advanced (from my perspective at least) CSS is used to completely change the look and feel of ListView and Button nodes.
  • It has neat dialog windows. The code for these should be pretty reusable.
  • It includes a 'location picker' written in JavaScript, but seamlessly incorporated into JavaFX thanks to the WebView.
  • It uses JFXtras for its CalendarTextField, which, truth be told, works great but looks hella-ugly.


How to use this application:

First, you need to set up the database. There's two ways to do this:
  1. In NetBeans, go to the Services window. Under Databases, right-click Java DB and create a new database with the following settings:
    • Name: Reminders
    • Username: APP
    • Password: APP
  2. Or create your own empty database and edit persistence.xml to use this database. Make sure you add the correct JDBC driver to the project.
Then, simply run the application. The database schema will be created upon first use. Once this is done, you can edit persistence.xml to set the table generation strategy to none.

The required libraries are found in the lib folder. You will also need EclipseLink and the Java DB Driver (if you chose option 1), but NetBeans already has those bundled with it.

Source code:

I hope you have fun with this. Let me know if something isn't working for you, or if you can't figure out the source code. As always, you can find me at myfirstname dot mylastname at icloud dot com (I already have plenty of spam, thanks).


  1. Does this example work from browsers too?

  2. Honestly, I've never tried it, as I couldn't care less about it. My personal opinion on applets is that they should have been deprecated over a decade ago. All they do is give Java a bad name anyway.

  3. Very nice! I was looking for this! But when i doesn't start the server in Netbeans the app doesn't work (derby's localhost doesn't start).

    How can i start the server by launching from a .jar file without starting the server?


    1. See the "How to use this application" section above. You can run from a .jar file just fine, as long as you set up the database first.

  4. If it's a problem using it outside of Netbeans, you need to use another driver for Derby and another url to use it outside of netbeans.

    Search this in Google, you'll find plenty of solutions.

    1. Thanks for the tip, but I can run it just fine outside of NetBeans, by double-clicking the jar-file.

  5. Muchas gracias por el aporte, yo tambien estoy trabajando con java fx y JPA 2.0 me ha servido de mucho

  6. Very nice example! Did you use some swing? Because when I ran it and switch reminders(switch lines) I got a annoying delay and a hard drive reading. I don't know maybe Netbeans! I am trying to learn JavaFX with Netbeans, but Netbeans lastest versions are buggy, all JavaFX project just works in DEBUG MODE or when I run the main class and there are lot of others strange things happening, I don't know. I am using Linux Mageia 3. Do you think JavaFX is ready for big applications? Is JavaFX faster than Swing?

  7. very helpful tutorial, i have already build an entire application with your Demo help.
    just i have one question about Dialogs, if i want to work with more than one dialog, from your Demo: if there's another Dialog above Reminder Details.(the parent is Reminder Details) how to mange that.
    Kind Regards

    1. I guess you could refactor the code so you can set the owner (parent) of a dialog yourself. In theory this should work. All that happens in the Dialogs class is that the current Stage is faded out, a new undecorated Stage is shown on top and, once it's closed, the parent Stage is faded back in. This should work equally well if the parent Stage is a dialog itself. If you're using JDK8, you might also want to take a look at the dialogs in ControlsFX:

    2. thanks so much for your help, i am using JDK7, i will try it and feedback.

  8. Steven

    I admit, I might be getting old now.
    But, how do I download the source code?
    I get redirected to a screen that shows all file but only allows me to download the file one-by-one.
    The URL also doesn't look like a GIT or SVN repo, what is it?

  9. It's just a zip-archive (with a NetBeans project inside) uploaded to Google Drive. This makes it easy for my students to download and use the code. Google probably shows you the contents of the archive. You can download the entire archive by using the File > Download command (from the site's menu bar, not from your browser's menu bar).