Java Swing中的MVC模式? [英] MVC Pattern in Java Swing?

查看:590
本文介绍了Java Swing中的MVC模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请给我一个Java SWING包中使用的MVC模式的例子?

解决方案

基本上,一个Swing组件本身就是控制器,它具有对视图和模型的引用。



视图位于 JComponent.ui 字段,组件并由Look& Feel机制使用以提供Swing组件的不同视觉表示。



有不同的 setModel()使用不同模型类型的各种子类的方法,例如 TableModel ButtonModel ,可以通过应用程序进行实现夯实Swing UI显示和操作的实际数据。


Please give me an example for MVC pattern used in Java SWING package ?

解决方案

Basically, a Swing component is itself a controller, which has a reference to a view and a model.

The view is in the JComponent.ui field that is inherited by all swing components and used by the Look&Feel mechanism to provide different visual representations of Swing components.

There are different setModel() methods in various subclasses that use different model types such as TableModel or ButtonModel, which can be implemented by an application programmer to contain the actual data that the Swing UI displays and manipulates.

这篇关于Java Swing中的MVC模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆