【问题标题】:How would I allow the user to move the view when they move the mouse off screen?当用户将鼠标移出屏幕时,我将如何允许用户移动视图?
【发布时间】:2011-04-10 01:30:03
【问题描述】:

我会实现视图移动,我只需要知道鼠标是否在屏幕外(offwindow)并相应地调整偏移变量。

【问题讨论】:

  • 如果鼠标移出窗口,您想移动窗口。

标签: java mouse mouseout


【解决方案1】:

也许您可以使用 MouseListener 来监听 mouseExited 事件。然后您可以使用 MouseInfo 类获取鼠标的当前位置,然后相应地重置窗口的位置。

如果鼠标移动得太快,重置位置后鼠标可能仍然在窗口之外,所以可能需要启动 Timer 不断检查 MouseInfo 以获取当前鼠标位置,然后不断调整窗口地点。如果在任何时候产生了 mouseEntered 事件,那么您可以停止 Timer。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多