Java:jLayeredPane 为不同层组件定义 mouseAdapter 时出现问题
我在 Java GUI 中使用 jLayeredPane。我在 jLayeredPane 的 DEFAULT_LAYER 上添加了一些面板(jPanelsLayer1),并且每个 jPanel 都有一个 MouseAdapter 来覆盖 mouseEntered 和 mouseExited 以满足我的目的。当我在 jPanelsLayer1 顶部的 JlayerdePane 的 PALETTE_LAYER 上添加另一个组件(jPanelsLayer2)并为它们定义 MouseAdapter 时,我遇到了问题。当鼠标进入公共区域时,不同层的jPanels的mouseEntered和mouseExited连续运行多次。我希望只有 jPanelslayer2 mouseAdapters 在 jpanelLayer1 顶部看到时才处于活动状态。也许一个解决方案是删除 jPanelLayer1 mouseAdapter。但这并不有效。
请指导我......萨贾德
I am using jLayeredPane in my Java GUI. I added some panels(jPanelsLayer1) on DEFAULT_LAYER of my jLayeredPane and also each jPanel has a MouseAdapter that Overrides mouseEntered and mouseExited for my purposes. When I add another components(jPanelsLayer2) on the PALETTE_LAYER of JlayerdePane, on the top of jPanelsLayer1, and defined MouseAdapter for them, I have problem. When mouse entered the common area mouseEntered and mouseExited of jPanels of different layers run consecutive several times. I want only jPanelslayer2 mouseAdapters to be active when they are seen on the top of jpanelLayer1. Maybe a solution be to remove jPanelLayer1 mouseAdapter. But this is not effective.
Please guid me.....sajad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您的问题出在哪里,因为当我测试它时,鼠标仅在位于“调色板”面板上方时在“调色板”面板中处于活动状态,即使“调色板”面板位于“默认”面板上方也是如此。例如,这是我的 SSCCE 来测试这个概念。请随意修改此内容以向我们展示您的问题:
I'm not sure where your problem is because when I test it, the mouse is only active in the Palette panel when it is above the Palette panel even if the the Palette panel is over the Default panel. For instance here is my SSCCE to test the concept. Feel free to modify this to show us your problem: