MVC with javaFX

前端 未结 2 433
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 09:24

I\'m struggling with the MVC concept using javaFX. I am building an javaFX application using fxml files.

Each fxml file has a controller assigned, but I don\'t think

相关标签:
2条回答
  • 2020-12-09 09:50

    You can try JRebirth with its custom-tailored pattern: wB-CS-Mvc

    This is a 2-level MVC pattern, first MVC (application-level) is CSM and the second one is Mvc itself (ui-level).

    • Wave for messaging and async internal event handling
    • Behavior to add common code to any Component (C|S|M)
    • Command to manage application commands (reusable code)
    • Service to handle some long service into thread pool
    • Model to manage the Model of your UI
    • View to create your UI
    • Controllers to handle user events

    You can run the JRebirth Tour Application to learn more (Java 8 required):

    http://apps.jrebirth.org/jaf/3.0.0/JRebirthTour-3.0.0.jar

    java -jar JRebirthTour-3.0.0.jar
    

    You can also run the Demo application:

    http://apps.jrebirth.org/demo/8.5.0/JRebirthDemo-8.5.0.jar

    java -jar JRebirthDemo-8.5.0.jar
    

    or browse slides (slightly outdated): http://fr.slideshare.net/SbastienBordes/javafx-unleashed-with-jrebirth-application-framework

    0 讨论(0)
  • 2020-12-09 09:55

    Thoughts on MVC

    MVC is a pretty loosely defined pattern which is open to (often somewhat vague) interpretations of what each of the things in MVC stand for (especially the controller). There is a great discussion of the MVC architecture with respect to GUI toolkits by Martin Fowler.

    On Design Patterns and FXML

    JavaFX core FXML based processing is built to be more of a toolkit rather than a complete development framework. The idea being that other frameworks could be layered on top of JavaFX and FXML and the underlying JavaFX/FXML implementations and the controllers for them would not push any kind of agenda or architectural constraints on the higher level frameworks.

    As a result, there is a deliberately loose analogy and mapping of core FXML based processing and their controllers to an MVC architecture.

    See JavaFX and MVP – a smörgåsbord of design patterns for further discussion.

    Consider using a higher-level framework

    You might benefit from adopting an "opinionated" JavaFX framework such as afterburner.fx, which utilizes controllers and FXML but provides a bit more of a rigid structured framework. Afterburner.fx follows a Model View Presenter (MVP) model. Though Afterburner.fx provides more functionality and structure than plain core JavaFX+FXML, it does so in a minimal way by adding few extra classes and APIs that you need to learn to use it.

    0 讨论(0)
提交回复
热议问题