SWT/JFace 相当于 JComponent.setDefaultLocale()?

发布于 2025-01-04 20:07:25 字数 549 浏览 3 评论 0原文

在 Swing 中,如果我想设置组件使用的默认语言环境,我可以调用 JComponent.setDefaultLocale()。我想在 SWT/JFace 中执行相同的操作,因此我的 JFace 对话框使用我选择的区域设置来显示“确定”/“取消”按钮等。SWT/JFace API 中是否有我可以调用的等效方法?

我知道我可以调用 Locale.setDefault(),但我想避免这种情况,因为应用程序的其他部分我需要它作为系统默认区域设置,而不是我的语言环境选择。

In Swing, if I want to set the default locale used by components, I can call JComponent.setDefaultLocale(). I want to do the same thing in SWT/JFace, so my JFace dialogs use a locale of my choosing to display the OK/Cancel buttons, etc. Is there an equivalent method in the SWT/JFace API that I can call?

I am aware that I could call Locale.setDefault(), but I would like to avoid this because there are other parts of the application where I need this to be the system default locale, instead of the locale of my choosing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰◇生如夏花灿烂 2025-01-11 20:07:25

从我在源代码中看到的情况来看 - 特别是 IDialogConstants.OK_LABEL 的值和类似常量的来源 - JFace 完全依赖于默认区域设置 (Locale.getDefault())。直接使用SWT,例如org.eclipse.swt.widgets.MessageBox,甚至会忽略Java 默认语言环境并以系统语言环境显示对话框。因此,似乎没有与 JComponent.setDefaultLocale() 等效的 SWT/JFace。

From what I've seen in the source code - especially where the values of IDialogConstants.OK_LABEL and similar constants originate - JFace completely relies on the default locale (Locale.getDefault()). Using SWT directly, e.g. org.eclipse.swt.widgets.MessageBox, will even ignore the Java default locale and display the dialog in the system's locale. So there seem's to be no SWT/JFace equivalent of JComponent.setDefaultLocale().

回忆追雨的时光 2025-01-11 20:07:25

据我所知,您应该能够使用您选择的语言环境:

  • swt-nl.jar 库(包含在您的类路径中)
  • 使用类似 java -cp ... - 的内容设置 user.language 库Duser.language=fr MainApp

请检查下载适合您需求的正确 swt-nl 包,有不同的可用...

HTH
杰罗姆

as far as I know you should be able to use the locale of your choice using :

  • the swt-nl.jar library (to be included in your classpath)
  • setting the user.language library with something like this java -cp ... -Duser.language=fr MainApp

Please check to download the correct swt-nl pack for your needs , different are available ...

HTH
jerome

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文