<legend id='95E8o'><style id='95E8o'><dir id='95E8o'><q id='95E8o'></q></dir></style></legend>

    <tfoot id='95E8o'></tfoot>

  • <small id='95E8o'></small><noframes id='95E8o'>

    <i id='95E8o'><tr id='95E8o'><dt id='95E8o'><q id='95E8o'><span id='95E8o'><b id='95E8o'><form id='95E8o'><ins id='95E8o'></ins><ul id='95E8o'></ul><sub id='95E8o'></sub></form><legend id='95E8o'></legend><bdo id='95E8o'><pre id='95E8o'><center id='95E8o'></center></pre></bdo></b><th id='95E8o'></th></span></q></dt></tr></i><div id='95E8o'><tfoot id='95E8o'></tfoot><dl id='95E8o'><fieldset id='95E8o'></fieldset></dl></div>
    • <bdo id='95E8o'></bdo><ul id='95E8o'></ul>

        将 Java Swing 桌面应用程序国际化的最佳实践是什么?

        What are the best practices for internationalizing a Java Swing desktop application?(将 Java Swing 桌面应用程序国际化的最佳实践是什么?)
        <tfoot id='hS0jq'></tfoot>
        • <bdo id='hS0jq'></bdo><ul id='hS0jq'></ul>

          <i id='hS0jq'><tr id='hS0jq'><dt id='hS0jq'><q id='hS0jq'><span id='hS0jq'><b id='hS0jq'><form id='hS0jq'><ins id='hS0jq'></ins><ul id='hS0jq'></ul><sub id='hS0jq'></sub></form><legend id='hS0jq'></legend><bdo id='hS0jq'><pre id='hS0jq'><center id='hS0jq'></center></pre></bdo></b><th id='hS0jq'></th></span></q></dt></tr></i><div id='hS0jq'><tfoot id='hS0jq'></tfoot><dl id='hS0jq'><fieldset id='hS0jq'></fieldset></dl></div>

            <tbody id='hS0jq'></tbody>

                • <small id='hS0jq'></small><noframes id='hS0jq'>

                  <legend id='hS0jq'><style id='hS0jq'><dir id='hS0jq'><q id='hS0jq'></q></dir></style></legend>
                • 本文介绍了将 Java Swing 桌面应用程序国际化的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我确信有很多方法,但推荐的方法是什么,对您的代码影响最小?

                  I'm sure there are a lot of methods, but what's the recommended way to do this that has the least amount of impact to your code?

                  很明显,您创建了属性文件,但是如何交换渲染中的值?在 J2EE 中,您总是只是重新呈现整个页面,因此很容易.但是在 Swing 应用程序中,您是否只需在 paintComponent(Graphics g) 方法中添加 .getProperty() 的代码?

                  The obvious is that you create properties files, but how do you swap the values in the rendering? In J2EE you always just re-render the whole page so it's easy. But in Swing apps, do you just add the code for the .getProperty() in the paintComponent(Graphics g) method?

                  如果是这样的话,它看起来不是很重,因为现在你必须在你不需要的地方重写这个方法......

                  If that's the case, doesn't it seem heavy since now you'll have to override this method everywhere where before you didn't need to...

                  附加:如何设置通知系统来重新渲染所有当前可见的组件,而不强制使用某种注册模式?

                  Additional: How do you setup a notification system to re-render all currently visible components without forcing some kind of registration pattern?

                  我想如果我覆盖了paintComponent(Graphics g),我所要做的就是触发一个事件发生了变化,然后调用paintComponent(Graphics g) 方法......

                  I guess if I overwrite paintComponent(Graphics g) all I have to do is fire an event that something has changed and the paintComponent(Graphics g) method will be called...

                  推荐答案

                  我想出的唯一解决方案是创建一个包含所有需要重新渲染的组件的大型注册表.然后,如果调用切换区域设置,您只需调用注册表,它将遍历所有已注册的组件并调整它们的值.因此,例如,对于所有已注册的 JLabels,它会按照以下方式做一些事情:

                  The only solution I came up with was to create a massive registry of all components that would need to be re-rendered. Then if a call is made to switch Locale you can just call the registry and it will go through all the registered components and adjust their values. So for example for all the registered JLabels it will do something along the lines of

                  for(JLabel specificJLabel : REGISTRY.registeredJLabels)
                  {
                    String localeKey = specificJLabel.getActionCommand();
                    specificJLabel.setText(ResourceBundle.getString(localeKey)); 
                  }
                  

                  Locale 键存储在组件 ActionCommand 中的位置.然后无论当前正在渲染什么屏幕,主父面板都负责重新渲染它.同样通过这种方式,注册表不必管理 Locale 键,这些键与注册表完全分离.每个组件负责管理它自己的 ResourceBundle 的 Locale Keys.

                  where the Locale key is stored in the components ActionCommand. Then whatever screen is currently being rendered, the main parent panel is responsible for re-rendering it. Also this way the registry doesn't have to manage the Locale keys, these are completely decoupled from the registry. Each component is responsible to manage it's own Locale Keys to the ResourceBundle.

                  这篇关于将 Java Swing 桌面应用程序国际化的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <bdo id='n2uta'></bdo><ul id='n2uta'></ul>

                        <small id='n2uta'></small><noframes id='n2uta'>

                        <tfoot id='n2uta'></tfoot>
                      1. <legend id='n2uta'><style id='n2uta'><dir id='n2uta'><q id='n2uta'></q></dir></style></legend>
                          <i id='n2uta'><tr id='n2uta'><dt id='n2uta'><q id='n2uta'><span id='n2uta'><b id='n2uta'><form id='n2uta'><ins id='n2uta'></ins><ul id='n2uta'></ul><sub id='n2uta'></sub></form><legend id='n2uta'></legend><bdo id='n2uta'><pre id='n2uta'><center id='n2uta'></center></pre></bdo></b><th id='n2uta'></th></span></q></dt></tr></i><div id='n2uta'><tfoot id='n2uta'></tfoot><dl id='n2uta'><fieldset id='n2uta'></fieldset></dl></div>
                            <tbody id='n2uta'></tbody>