Skip to main content
added 128 characters in body; edited tags
Source Link
Christophe
  • 82.2k
  • 11
  • 136
  • 202

I have a Javaan MVC application in Java with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties.properties files and I have a MyStrings.get(Key)MyStrings.get(Key) to get the string corresponding to Key. 

Should I call MyStrings.get(Key)MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key)MyStrings.get(Key) to the View constructor?

Option1:

Option1 - The View takes care of strings in its constructor:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT"));
}

Option2:

Option2 - The View gets the strings from the controler:

View(String buttonText) {
    button.setText(buttonText);
}

I have a Java application with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT"));
}

Option2:

View(String buttonText) {
    button.setText(buttonText);
}

I have an MVC application in Java with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. 

Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1 - The View takes care of strings in its constructor:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT"));
}

Option2 - The View gets the strings from the controler:

View(String buttonText) {
    button.setText(buttonText);
}
added 1 character in body
Source Link
Samil
  • 131
  • 5

I have a Java application with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT"));
}

Option2:

View(String buttonText) {
    button.setText(buttonText);
}

I have a Java application with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT");
}

Option2:

View(String buttonText) {
    button.setText(buttonText);
}

I have a Java application with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT"));
}

Option2:

View(String buttonText) {
    button.setText(buttonText);
}
Source Link
Samil
  • 131
  • 5

MVC: Should View get strings of GUI components directly or should the controller pass strings to View?

I have a Java application with GUI components in a View class. The GUI has to support two languages, so texts on buttons etc. depend on which language was set at start up. Strings are in .properties files and I have a MyStrings.get(Key) to get the string corresponding to Key. Should I call MyStrings.get(Key) in my View class constructor or should my Controller class pass the result of MyStrings.get(Key) to the View constructor?

Option1:

View() {
    button.setText(MyStrings.get("BUTTON_TEXT");
}

Option2:

View(String buttonText) {
    button.setText(buttonText);
}