如果您想了解更多详情,请告诉我们,或参考此问题的最后几行.我已经阅读了很多内容,我觉得我正在把一些简单的东西变成复杂的东西而且我仍然被困在那里,所以也许你可以在那些非常具体的方面帮助我.
我使用的是Netbeans IDE 7和JDK 7,没有框架.第一个窗口是JFrame,所有其他窗口都是JDialogs,模态=真.
问题:
如何使用swing正确实现MVC模式?从下面的想法哪一个更好:(A)或(B)?或者可能是另一个......为什么它更好?
(A)主要:
MyModel model
MyView view(model)
Run Code Online (Sandbox Code Playgroud)
我的看法:
MyController(this, model)
Run Code Online (Sandbox Code Playgroud)
(B)
主要:
MyModel model
MyView View
MyController controller(view, model)
Run Code Online (Sandbox Code Playgroud)当我在MainFrame中单击jbutton1时,我需要它来打开SettingsFrame进行编辑设置.我应该在哪里实例化SettingsFrame的View,Model和Controller?在MainFrame控制器?
在MVC组织和实现方面,我应该如何处理(显然)缺少一个或两个MVC"支路"(模型或视图或控制器)的更多特定功能?我应该为他们创建空课吗?
a. The implementation of a TrayIcon
b. A URL connection class (an HttpsUrlConnection which will update data in the main jframe and also upload/download files)
c. A Directory Monitor (which will update data in the main jframe and also use the urlconnection to download a file)
d. My own implementation of TableModel
e. json …Run Code Online (Sandbox Code Playgroud)