Swing组件和序列化 [英] Swing components and serialization

查看:79
本文介绍了Swing组件和序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么Swing JComponent 类实现接口 Serializable ?我实现视图的方式是无状态的,所有状态数据都存储在Presentation Model中。所以我不需要序列化我的观点。我使用了 @SuppressWarnings(serial)注释来删除警告。是否有更好的方法可以删除它们?

Why does Swing JComponent class implement the interface Serializable? The way I've implemented my views, they are stateless, all the state data is stored in a Presentation Model. So I don't need to serialize my views. I've used a @SuppressWarnings("serial") annotation to remove the warnings. Are there better ways to remove them?

推荐答案

在开始时,GUI构建器将以序列化格式保存UI。 applet 标签甚至还有一个从序列化表单加载的属性(我不知道其他人使用过它,我只是用它来表示恶意)。不幸的是,使用GUI的序列化机制并不真正起作用。 Swing只保证在同一个主要版本中的兼容性(我猜测甚至几乎没有测试)。

In the beginning GUI builders were going to save the UI in serialised format. The applet tag even has an attribute to load from serialised form (I don't know anyone else who has used that, and I've only used it to be malicious). Unfortunately using the serialisation mechanism for GUIs doesn't really work. Swing only guarantees compatibility in within the same major release (and I'm guessing even that has few tests).

这篇关于Swing组件和序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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