简体   繁体   English

JDesktopPane ContainerListener和JInternalFrame图标化事件

[英]JDesktopPane ContainerListener and JInternalFrame iconified events

So I have a desktoPane and it has containerListener. 所以我有一个desktoPane,它有containerListener。 I have this containerListener to add or remove buttons from taskbar when you add or remove internal frames. 我有这个containerListener来添加或删除内部框架时添加或删除任务栏中的按钮。 Everything was ok while I haven't clicked to minimize icon (-). 一切都很好,而我没有点击最小化图标( - )。 It came clear that when you minimize internalFrame it throws two events: 很明显,当你最小化internalFrame时,它会抛出两个事件:

  1. InternalFrame was removed; InternalFrame已被删除;
  2. DesktopIcon was added DesktopIcon已添加

and when you click restore it has again has two events: 当您单击还原时,它又有两个事件:

  1. DesktopIcon was removed; DesktopIcon已被删除;
  2. InternalFrame was added 内部框架已添加

As a result when you click minimize the button from taskbar disappears. 因此,当您单击最小化时,任务栏中的按钮消失。 So the question - how can I distinguish between "normal" events when you yourself add internalframe to desktopPane and these iconified events? 所以问题是 - 当你自己将内部框架添加到desktopPane和这些图标化事件时,我如何区分“正常”事件?

Don't use a ContainerListener for this. 不要为此使用ContainerListener That's a fairly low-level interface for watching the component hierarchy. 这是一个用于观察组件层次结构的相当低级的界面。 Instead use JInternalFrame.addInternalFrameListener . 而是使用JInternalFrame.addInternalFrameListener The InternalFrameListener interface fires dedicated methods for the opening, closing, minimizing and restoring events. InternalFrameListener接口触发用于打开,关闭,最小化和恢复事件的专用方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM