我应该始终使用 requestFocusInWindow() 而不是 requestFocus() 吗?
Should I use always requestFocusInWindow() instead of requestFocus()?
我读到 requestFocus()
有时会失败,因为它是基于平台的。
一般的经验法则是始终使用 requestFocusInWindow()
?
顺便说一下,我的应用程序是专为 macOS 开发的。
I read that requestFocus() sometimes fails because it's
platform-based.
是的。这是对的。 From Java Docs the requestFocus()
Note that the use of this method is discouraged because its behavior
is platform dependent. Instead we recommend the use of
requestFocusInWindow(boolean).
由于 依赖平台 不建议您在 Linux 中构建并且不会像 Windows 中预期的那样 运行。
requestFocusInWindow()
The focus behavior of this method can be implemented uniformly across
platforms, and thus developers are strongly encouraged to use this
method over requestFocus when possible. Code which relies on
requestFocus may exhibit different focus behavior on different
platforms.
我应该始终使用 requestFocusInWindow() 而不是 requestFocus() 吗?
视情况而定。如果你想你的应用程序 运行s 只在特定的 OS 中使用 requestFocus()
如果你想成为多平台使用 requestFocusInWindow()
如有疑问,请务必查看文档。
我读到 requestFocus()
有时会失败,因为它是基于平台的。
一般的经验法则是始终使用 requestFocusInWindow()
?
顺便说一下,我的应用程序是专为 macOS 开发的。
I read that requestFocus() sometimes fails because it's platform-based.
是的。这是对的。 From Java Docs the requestFocus()
Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow(boolean).
由于 依赖平台 不建议您在 Linux 中构建并且不会像 Windows 中预期的那样 运行。
requestFocusInWindow()
The focus behavior of this method can be implemented uniformly across platforms, and thus developers are strongly encouraged to use this method over requestFocus when possible. Code which relies on requestFocus may exhibit different focus behavior on different platforms.
我应该始终使用 requestFocusInWindow() 而不是 requestFocus() 吗?
视情况而定。如果你想你的应用程序 运行s 只在特定的 OS 中使用 requestFocus()
如果你想成为多平台使用 requestFocusInWindow()
如有疑问,请务必查看文档。