Init mit Aufgabe10
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
|
||||
package ChatProgramm.controller;
|
||||
|
||||
import ChatProgramm.controller.commands.CommandConnect;
|
||||
import ChatProgramm.controller.commands.CommandInvoker;
|
||||
import ChatProgramm.controller.commands.CommandSend;
|
||||
import ChatProgramm.view.ChatView;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ahren
|
||||
*/
|
||||
public class CommandController implements ActionListener{
|
||||
|
||||
private ChatView view;
|
||||
private CommandInvoker invoker;
|
||||
|
||||
public CommandController(ChatView view){
|
||||
this.view = view;
|
||||
this.invoker = new CommandInvoker();
|
||||
}
|
||||
|
||||
public void registerEvents(){
|
||||
view.getBtnConnect().addActionListener(this);
|
||||
view.getTfNachricht().addActionListener(this);
|
||||
}
|
||||
|
||||
public void registerCommands(){
|
||||
CommandSend commandSend = new CommandSend(view);
|
||||
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
|
||||
invoker.addCommand(view.getTfNachricht(), commandSend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausführen des jeweiligen Kommandos
|
||||
* @param e Referenz auf das Event
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Component key = (Component)e.getSource();
|
||||
invoker.executeCommand(key);
|
||||
// if(key == view.getBtnOpen()|| key==view.getMiOpen())
|
||||
// invoker.deleteStack();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user