1

I couldn't find any useful info about that. I wish to create a coplex objects from controls of a form-like UI - TextFields for numbers and strings and ComboBoxes for enums. Also, with a RadioButton group I have to be able to lock some of the controls and unlock anothers to create similar objects which inherit from the same base class. There's a big probability that the UI will change, either the object's properties, so I have to separate View from Model (or just UI from application's logic) to prevent from writing everything from the beginning because of the need of changing one of these two.

Are there any good practices, tools, classes etc. which help to write such a code in an elegant way using JavaFX? I'm not an experienced developer, but I heard that there are terms like DI or frameworks like Spring which may help. Unfortunately that must be something that I'm missing, because I have a completely no idea how to use such a things in my project, since it's not a web application.

I'll provide a real-life example to make it more clear:

I have a device which communicates with my PC by a serial protocol. On a device, there are various modes with various parameters which perform a specific actions regarding to the modes and parameters chosen. In a PC application I must fill the form to choose a specific mode and then fill its parameters (some are numbers, some enums, etc.). What I excactly want to achieve is that after filling all the TextFields and setting RadioButtons / ComboBoxes to the proper option and after clicking a single button with a text, let's say "Create a Mode", the MyMode object is created from the info provided by the user. And then, this MyMode object is used in another window for another thing. Somewhere else user may choose many modes which will later be presented next to another and which could be run on a device.

I'd like not to perform more actions than necessary to create and pass the MyMode object further. Problem is that I don't know where is the border between "you can make it in a Controller class" and "this is prohibited in Controller class". What I'm thinking about is to bring over all the information from the form and by using that information create an object with as few lines of code as it is necessary.

  • 1
    The model is just the class, or classes, that represent the data. In JavaFX it's recommended to use JavaFX properties in those classes, so that it's easy to observe and bind to them. So typically you define the model to represent the data, define the FXML to layout the controls, and define a controller (probably more accurately a "presenter") which links the view to the data in the model. Maybe http://stackoverflow.com/questions/32342864/applying-mvc-with-javafx helps? Your question is a bit general and broad. – James_D Feb 24 '17 at 16:12
  • @James_D I provided an example, hope it will help you to understand me better. – Przemysław Długoszewski-Tamoń Feb 24 '17 at 17:03
  • 1
    Oh, you are asking if there is any specific modeling tool that generates a bean from a form? Something like that? Otherwise I am not sure what you mean... you just write the code for the bean and instantiate it in a controller based on the data in the form. (If you are asking for a tool like that, I don't know of any, and that kind of question is off-topic anyway...) – James_D Feb 24 '17 at 17:11
  • @James_D Close but still no. I'm sorry, the problem is I don't know what am I seeking and that's why I can't describe my thoughts in a proper way. In one sentence - where to gather all the information from the form, where (on which layer -> Controller/Model) to create my ``MyMode`` object and how to do it in the most clear/elegant way? It's not about tools, more about techniques or even frameworks to make it good and to keep the code clean. – Przemysław Długoszewski-Tamoń Feb 24 '17 at 17:27
  • Did't I already describe that in my first comment? – James_D Feb 24 '17 at 17:36
  • I read more carefully the link you provided and think it described everything I needed. Thank you. – Przemysław Długoszewski-Tamoń Feb 28 '17 at 17:12

0 Answers0