Change the language of a text field

Hello to everyone, maybe you can help me.
I have a JTextFields which each one of them should have a different default language (english or hebrew).
How can I determine the default language of the JTextField.
I tried to do it using the class Robot but it isn't good enough because I can't find the current language. I tried to find the current displayed language using Locale but it didn't help. I also tried to write a character using the class Robot and then anlyse it but it also didn't help.
What can I do?
Is there a solution for this problem?
Does someone have any other ideas?

Java cannot translate the language for you. You have to provide a properties file for the Language.
For example, if you are in France, your locale is French.
Try this code.
languageManager.java
import java.util.*;
public class LanguageManager {
   private static final String BUNDLE = "conf.lang_IDE";
   public static LanguageResourceBundle getLanguage(UserPreferences userPref) {
      try {
      Locale locale = new Locale(userPref.getLanguage(), userPref.getCountry(), userPref.getVariant());
      ResourceBundle resource = ResourceBundle.getBundle(BUNDLE, locale);
      return (new LanguageResourceBundle(resource));
      } catch (IOException e) {
      ErrorDialog error = new ErrorDialog("Cannot Read the Language File", JOptionPane.ERROR_MESSAGE, "ERROR");
      return null;
LanguageResourceBundle.java
public class LanguageResourceBundle {
   private ResourceBundle resource = null;
   public LanguageResourceBundle(ResourceBundle resource) throws IOException {
      this.resource = resource;
   public String getString(String property) {
      return (resource.getString(property));
UserPreferences.java
public class UserPreferences {
   private String language;
   private String country;
   private String variant;
   public static String selectedLanguage;
   public static String selectedCountry;
    * Constructor, set the language, country and variant
   public UserPreferences() {
      setLanguage(getLanguageCode(selectedLanguage));
      setCountry(getCountryCode(selectedCountry));
      setVariant("");
    * Sets the Language
    * @param lang Language (in String) to be set
   public void setLanguage(String lang) {
      this.language = lang;
    * Returns the Language
    * @return Language
   public String getLanguage() {
      return language;
    * Sets the Country
    * @param country Country (in String) to be set
   public void setCountry(String country) {
      this.country = country;
    * Returns the Country
    * @return Country Code
   public String getCountry() {
      return country;
    * Sets the Variant
    * @param var Variant to be set
   public void setVariant(String var) {
      this.variant = var;
    * Get the Variant
    * @return Variant
   public String getVariant() {
      return variant;
}And your proprties file is some thing like this
lang.properties
MENU_FILE=File
MENU_FILE_NEW=New
MENU_FILE_OPEN=Open
So from your class, you use something like this
private LanguageResourceBundle language = LanguageManager.getLanguage(new UserPreferences());
menu1.setText(language.getString(MENU_FILE));This is how Language Resource Bundle works.
If your locale is french and you provide a proeprty file named lang_fr_FR.properties with French for example
MENU_FILE=Dossier
MENU_FILE_NEW=Nouveau
MENU_FILE_OPEN=Ouvert
then java picks the French file. and displays everything in French.
HTH

Similar Messages

  • Changing the background of a text field in adobe interactive forms

    Hello All,
    Is there any way to change the background colour of text field in interactive form dynamically.??
    Thanks,

    Naresh,
    Change the language to JavaScipt in Script Editor of LiveCycle Designer and use the following code to highlight the area of TextField where R,G,B means that you have to give the RGB values of the color you want.
    <YourTextFieldName>.border.edge.color.value = "R,G,B";
    For eg:- If you have a textfield with name TextField1 then this will highlight the TextField1 area in red color.
    if ((TextField1.rawValue==null) || (TextField1.rawValue==""))
      TextField1.border.edge.color.value = "255,0,0";
    You can use this on exit event of Textfield1 or at the submit button where you check the form data.
    Chintan

  • Dynamically change the size of a text field.

    Is it possible to change the size of a text field depending on the amount of text in the field?
    Thanks,
    Chad

    You can find the answer from this post.
    jimmypham, ""Shrink to Fit" - Text Field capability?" #1, 18 Jul 2005 10:36 pm

  • Change the background of a text field when a checkbox is checked?

    Hi,
    I'm new to Adobe JS, having done some browser scripting previously.
    I'm making a form in which I would like to change the background of a text field to bright yellow (RGB code 220,220,0) when a corresponding checkbox is checked?
    I have a checkbox named chkCD56, with an option value set to 1.
    I have a text field named CD56 with a transparent background.
    Can someone help me with the JS code?
    Thanks.

    Hi
    To make your number filed in Red :
    Right click on the field and go in format field click on Font tab and go in Color formula editor and give the following formula :
    If Sum(fieldValue} < 0 Then CrRed else CrNoColor
    Now go in Style formula editor and give the following :
    if sum() < 0 then Critalic
    This will make your field red and italic when it is less than 0
    Thanks,
    Sastry

  • A function to change the language in a text editor

    i develop a text editor in director MX and i want a function
    to can change the language with a button in english and in greek.
    Specifically the user will press the "greek button" if he
    want to write text on greek and the "english button" if he want to
    write text in english.
    thanks
    Sergios sergiou

    The latest version of ActiveCompanionSet xtras provides full
    control over keyboard layout. You may check the current
    layout/language and switch to another one. See details here:
    http://www.xtramania.com/Documentation/VbScriptXtra/Usage2/Wrappers/System/
    This functionality is free. You may just download and use
    it.

  • Problem, change the language with dynamic text

    I am looking for a way to change simply the language of my flash animation
    I work with flash cs4
    of course I got Mylocale.as:
    import mx.lang.Locale;
    class MyLocale extends mx.lang.Locale {
    static function start():Void {  
    var langCode:String = xmlLang;
    currentXMLMapIndex = 0;
    xmlDoc.load(xmlMap[langCode][0]);
    static function setXMLLang(langCode:String):Void {
    xmlLang = langCode;
    and different xml files in the same folder than my swf file
    in string , I ticked : "replace  strings automatically during the execution"
      with a default language (I am wondering if the problem is not from there)
      if I tick: "replace strings manually using the scene language " or "replace strings via actionscript"
    my code does not work.
      then I kept: "replace strings automatically during the execution"
    in my flash animation I have several scenes (pages)
    p1, p2, p3, p4
    in p1
    I created a language bar
    then 2 layers inside
    Layer--action:
    langListener = new Object();
    langListener.change = function(eventObj) {
    var target = eventObj.target;
    var newLang = target.selectedItem.data;
    MyLocale.setXMLLang(newLang);
    MyLocale.start();
    lang_cb.addEventListener("change", langListener);
    // Force Japanese
    lang_cb.selectedIndex = 1;
    lang_cb.dispatchEvent({type:"change"});
    Layer--language ex Fr:
    // Forces combobox to have the correct value
    on (release) {
    var component = _parent.lang_cb;
    for (var i=0; i< component.length; i++) {
    var item = component.getItemAt(i);
    if (item.data == "fr") {
    component.setSelectedIndex(i);
    component.dispatchEvent({type:"change"});
    break;
    ex Ja :
    // Forces combobox to have the correct value
    on (release) {
    var component = _parent.lang_cb;
    for (var i=0; i< component.length; i++) {
    var item = component.getItemAt(i);
    if (item.data == "ja") {
    component.setSelectedIndex(i);
    component.dispatchEvent({type:"change"});
    break;
    When I change the language in p1 , the language is also modified in p2, p3 and p4
    however , after a navigation in p2, p3 and p4 , once I come back in p1 , the default language is back automatically although I did not touch the language bar!!
    I don't know how to solve the problem
    to my mind , the script reset itself each time I come back on p1
    is there a way to keep the saved settings even when I am back on p1 until I modify manually again the language bar
    thanks a lot

    I am looking for a way to change simply the language of my flash animation
    I work with flash cs4
    of course I got Mylocale.as:
    import mx.lang.Locale;
    class MyLocale extends mx.lang.Locale {
    static function start():Void {  
    var langCode:String = xmlLang;
    currentXMLMapIndex = 0;
    xmlDoc.load(xmlMap[langCode][0]);
    static function setXMLLang(langCode:String):Void {
    xmlLang = langCode;
    and different xml files in the same folder than my swf file
    in string , I ticked : "replace  strings automatically during the execution"
      with a default language (I am wondering if the problem is not from there)
      if I tick: "replace strings manually using the scene language " or "replace strings via actionscript"
    my code does not work.
      then I kept: "replace strings automatically during the execution"
    in my flash animation I have several scenes (pages)
    p1, p2, p3, p4
    in p1
    I created a language bar
    then 2 layers inside
    Layer--action:
    langListener = new Object();
    langListener.change = function(eventObj) {
    var target = eventObj.target;
    var newLang = target.selectedItem.data;
    MyLocale.setXMLLang(newLang);
    MyLocale.start();
    lang_cb.addEventListener("change", langListener);
    // Force Japanese
    lang_cb.selectedIndex = 1;
    lang_cb.dispatchEvent({type:"change"});
    Layer--language ex Fr:
    // Forces combobox to have the correct value
    on (release) {
    var component = _parent.lang_cb;
    for (var i=0; i< component.length; i++) {
    var item = component.getItemAt(i);
    if (item.data == "fr") {
    component.setSelectedIndex(i);
    component.dispatchEvent({type:"change"});
    break;
    ex Ja :
    // Forces combobox to have the correct value
    on (release) {
    var component = _parent.lang_cb;
    for (var i=0; i< component.length; i++) {
    var item = component.getItemAt(i);
    if (item.data == "ja") {
    component.setSelectedIndex(i);
    component.dispatchEvent({type:"change"});
    break;
    When I change the language in p1 , the language is also modified in p2, p3 and p4
    however , after a navigation in p2, p3 and p4 , once I come back in p1 , the default language is back automatically although I did not touch the language bar!!
    I don't know how to solve the problem
    to my mind , the script reset itself each time I come back on p1
    is there a way to keep the saved settings even when I am back on p1 until I modify manually again the language bar
    thanks a lot

  • How can I change the content of a text field in a PDF form with a defined variable?

    Hello all!
    First time poster, and getting pretty frustrated with trying to figure out this one issue. Here is the scenario: I am using Acrobat 10 Pro to design what is essentially a giant order form. I designed the document in InDesign, defined the various buttons and whatnot and then exported it to Acrobat to continue building the form.
    I have a Radio Button group called "conference_opportunities" which contains different options at different price points, so they are all named the same, but have different values (so that they belong to the same group and only one can be selected at a time).
    What I have done is created a "MouseDown" event on the radio button that sets a variable called "ConferenceOpportunity" which is equal to the title of the option they are picking. I then want to take that variable and display it in a text box called "Conference_Option". I am using a variable because the values of my radio buttons are all the actual prices of the option they are picking, so I can't define the value as the title of the option.
    So its an array of radio buttons, and at the bottom of the page there is the Option They Selected, the quantity (which can change) and the value (in dollars)
    I also then want to display this variable at the end of the document as a sort of summary of everything they chose to purchase as well but I imagine its the same code.
    I am not an expert Javascript person at all, so any code snippets would help greatly. I have looked over the Adobe Document on the SDK and API and have not been able to find a solution. I have also turned to the almighty google and still no luck.
    Any help would be greatly appreciated!
    Thanks Everyone

    All you now have to do is use that variable to the value property of your text field... So add this at the end of your code:
    this.getField("Conference_Option").value = ConferenceOpportunity;
    Also, I would use MouseUp, not MouseDown.

  • How does one change the "rollover" value in text field of fillable PDF

    I have a fillable PDF, and the values displayed when rolling the pointer over a fillable text field are showing some strange values.  I inherited this form from someone who is no longer with the company.  I need to be able to change the values but can't figure out how.  I'm new to LiveCycle so any help is greatly appreciated.

    I guess you are referring to "Tool Tip" you can update those in "Accessibility" Pallet...in designer you would access this by Shift+F6.

  • How can I change the Background in a text-field into lets say grey?

    I created a text field and now I would like to not have the background in white. I did not figure out yet how I can do this. Also the help program did not help. Does anybody know how this works?
    Thanks a lot. Many greetings!

    Oh.. all right, forget it.. I just found it myself.... just looking a little more... Thanks for your help anyway....

  • How to change the font in a text field?

    I am trying to recreate a file like this:
    http://www.teacherspayteachers.com/Product/Thank-You-Cards-for-Volunteers-Freebie-Editable Customizable-696763
    I originally created the file in Powerpoint, saved as a PDF, brought it into Adobe Pro XI for Mac.  I edit it in forms, and add a text form field, which inserts a blue box, with text1 in the middle.  How do I replace that with different font and size, in the above example, she has a different font in a larger size.  When I look at the properties, I am limited up to 8 point font.  I have been at this for hours now, so any help would be greatly appreciated, especially step by step.  Thanks.

    Click on each field and the choose Properties from either File menu (or if on Mac hold dow mouse button until context menu appears choose properties)
    go to Font
    choose desired size and type font,you can choose to make this the default.
    Do this with each field.
    Or if you have a lot of fields:
    while one is selected select all of them
    then go to fonts in properties
    change Font and size and make default.

  • How do i change the language of my text?

    pages think i'm writing danish and the spell checker messes up! I have looked in toolbar, menus, boxes -

    But aren't you Danish?
    What language do you want?
    What language have you set in your System Preferences?
    How does the spell checker "mess up".
    Just for the sake of this discussion pretend we are not in the room with you and can't see what you are looking at.
    Peter

  • How can I change the caption of a text field using data?

    Hi, I've read that this is possible to do but when you have an xsd file, I'm using a preview xml data file, so there is no way to link them together, any ideas?.
    Thanks!.

    1) In Designer, Tools>Options
    2) Select Data Binding in the left pane and make sure Show Dynamic Properties is checked
    3) Select the field that you want the caption to be driven by XML
    4) In the Object palette under the Field tab you'll notice Caption is now green and underlined, click it.
    5) If your form is bound to a schema you can see the hierachy when you press the button beside the binding entry field or in your case to access the Caption attribute in your XML type> $.textField1.Caption
    Assuming '$' is your root node.
    Kyle

  • How do i change the language of my keyboard and autocorrect to write a text in spanish using the pages app

    how do i change the language of my keyboard and autocorrect to write a text in spanish using the pages app?

    Edit > Spelling and Grammar > Show Spelling and Grammar

  • How can I change the language of a block of text

    Hi,
    Working in a bilingual environment, I am constantly switching languages as I write e-mail. Using Mail 3.5, if I forget to change the dictionary language before I start writing, Mail logically marks most words as spelled incorrectly. After having written a paragraph, I'd like to be able to change dictionary language, and then continue writing.
    But Mail doesn't seem to change the language for the text that was already entered -- the words that were "misspelled" according to the old dictionary language are still underlined in red after the new dictionary is chosen, and after I've told it to "Check document now".
    How can I get it to re-evaluate the text as now being in the language of the dictionary, so that all those incorrect red underlines will disappear?
    Thanks,
    Eric Peters

    "It's not a bug or a feature; it's just something you can't do..."
    Phooey! I accept that Mail is limited to one language at a time. I don't accept that the spell checking fails to work if I switch which dictionary is in use after having already written some text.
    "I know of no email client for Mac than can do it, either."
    Er, I hate to say it... MS Entourage does do it, perfectly.
    I recently gave up Entourage and switched to Mail, because I decided to stick to all Apple software so that syncing would be smoother. The syncing does work much better now that I've eliminated Entourage from the equation...
    ...but why can't I switch languages and get the dictionary to evaluate the text in the language I've chosen?! Otherwise, can someone explain to me the meaning of allowing the user to select a new language from the popup in the "Show Spelling and Grammar" dialog, if that new language won't then be used for spell-checking, whether for all the text, or the selected text? What is the purpose of allowing use of an interface control which doesn't then do what it obviously is supposed to do? It seems like Apple has broken its own HIG here.
    Thanks for listening... maybe someday it will work as it obviously should!
    Eric Peters

  • Hi, how do I change the language settings in pages (newest version)? I tried to find the setting text - more - but cannot find it. Thanks.

    The language cannot be found via the help aid and I am unable to change the language setting. Thanks for any help!

    cfs234 wrote:
    The language cannot be found via the help aid and I am unable to change the language setting. Thanks for any help!
    Inspector > Text > More > Language

Maybe you are looking for