序列化 JTabbedPane

发布于 2024-10-17 03:20:54 字数 304 浏览 5 评论 0原文

在 Java GUI 代码中,我使用名为 tabpaneJTabbedPane。该tabpane具有动态功能,即用户可以添加、关闭选项卡并且可以更改选项卡内容。

据我所知,整个 tabpane 在执行期间保留在随机存取存储器中。但我只需要当前选定的选项卡保留在 RAM 中,而其他选项卡则不需要。其他的应该写入磁盘内存并在调用时加载到 RAM 中。

我认为这是可能的,因为 JTabbedPane 是一个可序列化的组件。但实现这一目标的具体程序是什么?

In a Java GUI code I use a JTabbedPanecalled tabpane. This tabpane has dynamic functionality, that is tabs can be added, closed and tab contents may changed by the user.

As far as I know the entire tabpane remains in the Random Access Memory during execution. But I need only the currently selected tab to remain in RAM and others not. Others should be written in disk memory and loaded in RAM whenever they are called.

I think it is possible as JTabbedPane is a Serializable component. But what are the exact procedures to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦情居士 2024-10-24 03:20:54

您不能序列化部分 GUI,而只能序列化整个组件图。一种可能性是将每个窗格序列化在单独的文件中,并在需要时反序列化这些窗格,但随后您必须手动构建父选项卡及其上方的所有内容,这可能不是您想要的。

You cannot serialize a partial GUI, but only the whole component graph. One possibility would be to serialize each pane in separate files, and deserialize those when needed, but then you have to manually construct the parent tab and everything above it, which is propably not what you want.

眼眸印温柔 2024-10-24 03:20:54

JTabbedPane 确实是Serialized。但是为了解决您的问题,最好有一个属性文件,并且您的程序在读取属性文件后,确定需要哪些选项卡并创建一个新的 JTabbedPane 并使用它。序列化 JTabbedPane 不会被证明太有用。

It is true that JTabbedPane is Serializable. But to the solution of your problem, it will be better to have a properties file, and your program after reading the property file, determine which tabs are required and create a new JTabbedPane and use it instead. Serializing the JTabbedPane will not prove to be too useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文