package view;

import javax.swing.*;
import java.util.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import model.Language;
import controller.Controller;

public class LangView extends BaseView {
	private Controller controller;
	private Language language;

	public LangView(Controller controller) {
		super();
		this.controller = controller;
		setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
		LangButton engBtn, fraBtn, japBtn;
		engBtn = new LangButton("English", controller);
		fraBtn = new LangButton("Français", controller);
		japBtn = new LangButton("日本人", controller);
		add(engBtn);
		add(fraBtn);
		add(japBtn);
		controller.init(this);
	}

	public void setLanguage(Language language) {
		this.language = language;
		super.setTitle(language.getString("language"));
	}

	public void update (Observable o, Object arg) {

	}
}

class LangButton extends JButton implements ActionListener {
	private String lang;
	private Controller controller;

	public LangButton(String str, Controller controller) {
		super(str);
		lang = "fr";
		if(str.equals("English"))
			lang = "en";
		if(str.equals("日本人"))
			lang = "ja";
		this.controller = controller;
		addActionListener(this);
	}

	public void actionPerformed(ActionEvent e) {
		controller.languageSelected(lang);
	}
}

@@ -854,16 +854,101 @@
  arg) %7B%0A
+%09%09String tmp = (String)arg;%0A%09%09if(tmp.equals(%22language%22))%0A%09%09%09setLanguage((Language)o);
 %0A%09%7D%0A%7D%0A%0Ac

fix lang view title