打开 JMenu 时收到通知? (例如:文件、编辑、查看)
我想要做的是,当我的 Edit JMenu
被单击时,在它出现之前,我想根据撤消/重做命令是否可见来设置启用它们。
有没有办法获得这样的通知?是 MenuListener
我在寻找什么?
What I want to do is, when my Edit JMenu
is clicked on, before it appears I want to set enabled on the undo / redo commands based on whether or not they should be visible.
Is there a way to get such a notification? Is MenuListener
what I'm looking for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用 MenuListener,扩展的
EventListener
,并启用menuSelected
中的撤消/重做项。现在我想起来,这对我来说可能是一个更好的方式来做一些非常类似的事情。当我的历史对象报告没有更多撤消/重做命令时,我在视图中启用/禁用了
undo
/redo
方法中的项目> 左。编辑:我发现在我有机会发布此帖子并亲自找到
MenuListener
之前,您一定已经快速编辑了您的帖子。You should be able to use a MenuListener, an extended
EventListener
, and enable the undo/redo items inmenuSelected
.Now that I think about it, that probably would've been a better way for me to have done something very similar. I instead enabled/disabled the items in an
undo
/redo
method in my view when my history object reported that there were no more undo/redo commands left.EDIT: I see you must've quickly edited your post before I had the chance to post this and found
MenuListener
yourself.