将包含 Swing 面板的容器从一个容器移动到另一个容器后,OfficeBean 将不会显示

发布于 2024-09-06 16:46:00 字数 566 浏览 3 评论 0原文

我正在开发一个Java 6小程序,它允许用户查看OO(v.3.2)文档(只读),如果他们选择,单击一个按钮,启动一个新的JDialog窗口,其中显示的文档允许用户按照他们的意愿对其进行标记和编辑。完成后,他们可以关闭 JDialog,它将文档保存到服务器并在原始小程序窗口中重新显示更新的文档(再次只读)

我猜我可以使用嵌入的 OfficeBean 的单个实例来完成此操作在 Swing 面板中。但是,当单击“Redact”按钮时,我似乎无法成功地将面板(包含 OfficeBean)从小程序移动到 JDialog。我得到的只是 JDialog 中文档应在的空白区域。我没有收到任何错误。

目前,我已经设法通过在每次需要显示文档时创建 OfficeBean 的新实例来解决这个问题(一次是在加载小程序时,一次是当用户选择编辑并在 JDialog 中打开它时,最后是当他们单击对话框中的“保存”,编辑后的结果将再次显示在小程序中。)但这意味着往返于文档来源服务器的三次往返。我觉得这很疯狂。

我绝不是 Swing 专家,很可能犯了一个愚蠢的错误。然而,我已经做了很多摆弄、调试和谷歌搜索,但似乎无法让它工作。有人能帮我吗?我是否正在尝试做一些根本不可能的事情?我希望不会。

I'm developing a Java 6 applet which allows users to view OO (v.3.2) documents (read only), and if they choose, click a button which launches a new JDialog window, with the document displayed in it which allows the user to and mark and redact it as they wish. Once they are done, they can close the JDialog, which saves the document to a server and redisplay the updated document (read-only again) in the original applet window

I guessed that I could do this with a single instance of an OfficeBean, embedded in a Swing Panel. However, I cannot seem to successfully move my Panel (containing the OfficeBean) from the applet to the JDialog when the "Redact" button is clicked. All I get is a blank area in the JDialog where the document should be. I get no errors.

I have currently managed to get round this by creating new instances of the OfficeBean every time I need to display the document (once when the applet is loaded, again when the user chooses to redact and it is opened in a JDialog, and finally when they click "Save" in the dialog and the redacted result is displayed in the applet again.) However this means three trips to and from the server where the documents originate. That seems mad to me.

I'm in no way a Swing expert and may well be making a silly mistake. However, I've done a lot of fiddling around, debugging and googling and can't seem to get this to work. Can anyone help me in this? Am I trying to do something which is fundamentally impossible? I hope not.

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

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

发布评论

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

评论(1

妳是的陽光 2024-09-13 16:46:01

Swing 中的一条规则是组件一次只能显示/附加到 gui“树”的一部分。当您将组件“移动”到对话框时,是否首先将其从小程序中删除?

One rule in Swing is that a component can only be displayed / attached to one part of the gui "tree" at a time. When you "move" your component to the dialog, are you first removing it from the applet?

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