package GUIAnwendungen.Meine_GUI_Chat;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Controller {
	
	private Modell user1;
	private View view;
	private View_Hauptfenster h1 = new View_Hauptfenster();
	private String name;
	private String password;
	
	Controller(Modell user, View view){
		this.user1 = user;
		this.view = view;
	}
	
	public boolean logIn() {
		view.getLogIn().addActionListener(new ActionListener(){
			 public void actionPerformed(ActionEvent e) {
					name = view.getNameEingabe();
					password = view.getPasswordEingabe();
					user1 = new Modell(name,password);
					view.zeigeUserInfos();
					view.schließeLoginFenster();
					zeigeHauptfenster();
	            }
	        });
		return true;
	}
	
		
	public void zeigeHauptfenster() {
		h1.zeigeBegrüße(user1.getName());
		
		h1.setVisible(true);
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Modell getUser1() {
		return user1;
	}
	
	
	
}
