Friday, March 14, 2014

DietOnJava - JavaFX desktop app

Well, this is my project and this post is an overview of it, I'll explain the basics although it's pretty straightforward as you can tell from the GUI.

I'm making an application for a friend of mine, he's a dietitian and asked me if I could make him an app to create diet programs for his clients. Yes, there are many similar programs (professional ones) out there but he wanted a specific GUI and also this would be a great exercise for me, although I'm a noob Java programmer.

Do NOT expect awesome code and such, I have some experience with Java yes, but this will be my first full-application with JavaFX, GUIs, DBs etc. Also, I haven't implemented any functionality yet, I'm questioning whether I should continue like this or re-write it with another approach, you tell me.

Dev Environment:

I've started building the application on NetBeans 7.4 (now using 8 RC1), Java7 SE and Scene Builder 1.1. Scene Builder was used to create the FXML layout, it's extremely easy this way.

I have an SQLite database that holds the food data, it's a single huge table with all the data, certainly not the most optimal solution but hey, this is my first try on developing something like this.


The Main DB tableview, shows the SQLite database. The buttons below it are self-explanatory, they add, edit and delete entries from the database.

Above the tableview, the client's info are entered and you can select a picture if you like.

The tableviews to the left constitute the diet for each day, you have 5 meals for each day plus a tableview that holds the total sums for each nutrient (total water, total iron, total cholesterol etc).

Foods are added to the meals by dragging and dropping from the main database, to delete foods from the meals maybe double clicking, I'm not sure yet.

This whole screen will be saved probably to XML documents, you'll have a single XML document for each diet schedule. Or JSON, I don't know. I've found libraries that do that so it'll be easy I guess.


That's basically it. There are no "blueprints", no UML, nothing. I look at the GUI and try to see what needs to be done. Since it's object interaction, it's kind of clear what I need to implement.

I haven't worked on the application for a couple of months due to uni exams, I'm really excited to pick it up again but I'm debating whether I'm on the right thought process or not.

ANY kind of feedback would be extremely helpful, I'm here to learn anyway. I have the project on GitHub under a Creative Commons license so feel free to take a look at my (now quite nonexistent code).


  1. Thanks man :)

    It's going to be truly awesome when I add all the stuff I want.

  2. Very good nice work, you need to add some style and it will be great!
    Συγχαρητήρια, από έναν μικρό προγραμματιστή που ασχολείται και αυτός με javaFX :)

    1. Thank you :) Yes, styling is definitely a must. I'm leaving it for later though because I know very little CSS at the moment.
      Καλή φάση η JavaFX, και μόνο που λένε ότι θ' αντικαταστήσει το Swing, αξίζει ν' ασχοληθείς.

  3. Has your friend/client reviewed your UI? Make sure you and your friend agree on usability before you go any further.
    Also, you might want to add a way for the user to account for snacks or desserts after dinner.

    1. Yes, we made the UI first, he wanted everything on a single screen :)

      Snacks etc; he adds them to the corresponding meal table according to the weekly diet.

      Actually, when time comes for major (or total) re-write of the app, I'll probably study similar products and make mine more professional...

      Thanks a lot for your time and feedback!

  4. A good start for Javafx:) A small advice from me is, try splitting your screen in a few independent components using fx's compoments. For example you can separate the AnchorPanes for each side of the SplitPane or even have an HBox with all the buttons on top of the right side. The result will be to have a different .fxml file for each component you decide to use for splitting the interface. And each one will have its own controller class. I found out that this made my code more manageable and modular and may even help you with the styling. :)

    1. Thank you very much :) Yes you're correct, I should have split it into different components, now my controller class is a bit of a mess. Manageable but still...
      I'll see what I can do when I start working on it again, it's on halt right now due to lack of time, but this advice right here is golden!

  5. As of the question on whether javafx is useful I still don't have the answer. It will certainly have find a place opposite any more web based solutions like the new js frameworks, html5 etc. This is the truth and the answer is difficult. At least until it is possible to have javafx on mobile devices.