Hi! here I've got a Selector class which shows a combo box and a label, in the combo box the user can select the language in which he wants the label to be showed, getting the translation from the Datos.PROPERTIES file. That works fine.
Now I need to extend it so that this selection class selects the language of all the menues of an application.
The question is: do I have to add all the labels of the application in the if-then-else sentence of the selection class? I mean that in the selection class I show here there's an if then else sentence depending on the language selected, do I have to put all the labels of all the menues of the application in there?
The question is: do I have to add all the labels of the application in the if-then-else sentence of the selection class?
1) Extend JLabel and call it say RBLabel 2) Whenever you create a new instanceof RBLabel add it as an action listener to the JComboBox so that whenever the user changes the value in the JComboBox, all the instances of RBLabel get notified. 3) In actionPerformed() of RBLabel write the code which will get the selected language, load the correct resource bundle and get the translated text. Once you get the translated text, you can always call this.setText(translatedText)
To make it more elegant you can consider a utility class which will do the job of loading the resource bundle. In that case you will need a method in the utility class which will provide you the translated text.