(SWING) 菜单栏操作和状态保持

发布于 2024-10-19 10:33:24 字数 267 浏览 6 评论 0原文

我正在编写一个有点类似于 MS Excel 的客户端应用程序 - 它有一个菜单栏,并且有几个内部框架,每个框架都是处于几种状态之一的文件。

基本流程是这样的:打开文件后,可以点击构建,构建完成后可以导出/保存(其他场景更复杂)。

我感兴趣的是如何在每次在框架之间切换时更改菜单按钮的状态:如果您还没有按下“构建”,则应该禁用“导出”,但是如果您切换到窗口您已经按下“构建”按钮并构建了“导出” 按钮应该被启用。

有没有一种设计模式可以处理这样的事情?有哪些最著名的方法?

I'm writing a client app that's a bit similar to MS Excel - It has one menu bar , and you have several inner frames , each frame is a file in one of several states.

The basic flow is this : After opening a file , you can click on build , and after the build is completed you can export/save it (others scenarios are more complex).

What I'm interested in is how to change the state of the menu buttons every time you switch between frames: if you haven't pressed the "build" yet , the "export" should be disabled , but if you switch to a window where you've already pressed the "build" button and it's built , the "export"
button should be enabled.

Is there a design pattern for handling something like this? Any Best Known Methods?

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

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

发布评论

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

评论(1

仅此而已 2024-10-26 10:33:24

添加一个 InternalFrameListener 到您创建的每个内部框架,并侦听 internalFrameActivated 事件。该事件包含已激活的框架。询问该内部框架的状态,了解其是否已构建,并相应地启用/禁用菜单项。

Add an InternalFrameListener to every internal frame you create, and listen for internalFrameActivated events. The event contains the frame which has been activated. Ask this internal frame its state, to know if it has been built, and enable/disable the menu items accordingly.

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