(SWING) 菜单栏操作和状态保持
我正在编写一个有点类似于 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加一个
InternalFrameListener
到您创建的每个内部框架,并侦听internalFrameActivated
事件。该事件包含已激活的框架。询问该内部框架的状态,了解其是否已构建,并相应地启用/禁用菜单项。Add an
InternalFrameListener
to every internal frame you create, and listen forinternalFrameActivated
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.