Skip to main content
1 of 3
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);
}
Samil
  • 131
  • 5