#Java / JavaFX MVC model

1 messages · Page 1 of 1 (latest)

regal warren
#

How would you implement the MVC model?
I currently got some code but thats the UI plus some calculations made with the inputs from the UI

terse spearBOT
#

<@&987246487241105418> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question 🤖. Maybe it helps! In any case, a human is on the way 👍. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
How would you implement the MVC model? I currently got some code but thats the UI plus some calculations made with the inputs from the UI

To implement the MVC (Model-View-Controller) model in a JavaFX or Swing application, you can follow these steps:

  1. Model: This represents the data and business logic of your application. Create classes that contain the necessary data and methods for manipulating it. Ensure that these classes are independent of the UI.

  2. View: This is the UI component of your application. In JavaFX, you can create FXML files for designing the layout and use controllers to handle user interactions. In Swing, you can create GUI components programmatically.

  3. Controller: This acts as an intermediary between the Model and View. It receives input from the user via the View, interacts with the Model to perform any necessary calculations or data manipulation, and updates the View accordingly.

To separate concerns effectively:

  • Move your calculations out of the UI code into a separate class that acts as a model.
  • Create event handlers in your controllers to handle user interactions and update the model accordingly.
  • Use listeners or bindings to update the UI when changes occur in the model.

By following these guidelines, you can achieve a clean separation of concerns in your JavaFX/Swing application and implement the MVC pattern effectively for better maintainability and scalability.

regal warren
# terse spear

so i would just need to google how to connect the files and how to make them work together?