为什么Java Swing可序列化? [英] Why is Java Swing serializable?

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

问题描述

当我为远程用户创建Swing应用程序时,我只创建jar文件并创建一个WebStart文件,让用户下载应用程序然后运行它。我没有听说过提供JFrame等的应用程序服务器,比如JSP。这是原意吗?

When I create Swing apps for remote users, I just create jar files and create a WebStart file to let users download the app and then run it. I haven't heard of application servers serving up JFrames, etc, like JSPs. Was that the original intent?

推荐答案

我过去实际上曾经使用过它。构建一个编译器,接收XML数据,配置和构建您的显示对象,将它们序列化,然后将它们传递给瘦客户机,除了UI和简单的回调之外,它不知道任何东西。

I've actually used it in the past. Build a compiler that takes in XML data, configures and builds your display objects up, serialize them and then pass them on to a thin client that doesn't know anything beyond UI and simple callbacks.

当然事实证明它非常低效。我们将数据分成不同的类并使用它的实例作为我们的显示对象构造函数的参数。

Of course it turned out to be terribly inefficient. We wound up seperating the data into a different class and using an instance of that as a parameter for our display object constructors.

我没有理由想到有摆动物体本身可序列化,但易于使用。事实上,事实证明它有点危险,因为我们认为如果它们首先使它可序列化,那么它就不会那么糟糕。

There's no good reason I can think of to have the swing objects themselves serializable, except for ease of use. In fact it turned out to be a little dangerous, since we thought "if they made it serializable in the first place, then it can't be that bad an idea."

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

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