gpt4 book ai didi

java - 如何重新关注在 Solaris 计算机上运行的 Swing Java GUI?

转载 作者:行者123 更新时间:2023-12-01 15:24:41 25 4
gpt4 key购买 nike

大家好,我正在 Solaris 平台上开发 java swings GUI,我希望我的应用程序始终具有焦点,并且仅当我单击按钮时才更改,我必须这样做以满足实际上看起来可能的要求非常愚蠢...请告诉我是否有任何简单的解决方案:P

最佳答案

来自How to Use the Focus Subsystem :

Exactly how a window gains the focus depends on the windowing system. There is no foolproof way, across all platforms, to ensure that a window gains the focus. On some operating systems, such as Microsoft Windows, the front window usually becomes the focused window. In these cases, the Window.toFront method moves the window to the front, thereby giving it the focus. However, on other operating systems, such as Solaris™ Operating System, the window manager may choose the focused window based on cursor position, and in these cases the behavior of the Window.toFront method is different.

记住这一点,您需要找到一种方法来让您的应用程序在 Java 中获得焦点,并与您的窗口管理器配合使用。您可以尝试将窗口设置为“始终在顶部”,但同样,仍然取决于窗口管理器是否尊重该愿望。如果您可以做到这一点,您可以安排一个 TimerTask 来定期向您的窗口请求焦点。但这非常烦人,暗示它让我感觉很肮脏。

关于java - 如何重新关注在 Solaris 计算机上运行的 Swing Java GUI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10335096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com