com.harium.etyl.ui.label.MultiLangLabel Maven / Gradle / Ivy
package com.harium.etyl.ui.label;
import com.harium.etyl.commons.event.GUIEvent;
import com.harium.etyl.i18n.Language;
import com.harium.etyl.i18n.LanguageModule;
import java.util.Map;
public class MultiLangLabel extends TextLabel {
private Map texts;
public MultiLangLabel(Map texts) {
this(0, 0, texts);
}
public MultiLangLabel(int x, int y, Map texts) {
this(x, y, 0, texts);
}
public MultiLangLabel(int x, int y, int w, Map texts) {
super(x, y, w);
this.texts = texts;
Language lang = LanguageModule.getInstance().getLanguage();
reloadText(lang);
}
@Override
public void updateEvent(GUIEvent event) {
if (event == GUIEvent.LOST_FOCUS) {
onFocus = false;
} else if (event == GUIEvent.GAIN_FOCUS) {
onFocus = true;
} else if (event == GUIEvent.LANGUAGE_CHANGED) {
reloadText(LanguageModule.getInstance().getLanguage());
}
}
public Map getTexts() {
return texts;
}
public void setTexts(Map texts) {
this.texts = texts;
}
private void reloadText(Language lang) {
if (texts.containsKey(lang)) {
setText(texts.get(lang));
} else {
setText(texts.get(Language.ENGLISH_US));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy