61 lines
1.7 KiB
Java
61 lines
1.7 KiB
Java
/*
|
|
* 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.commands;
|
|
|
|
import ChatProgramm.model.ChatModel;
|
|
import ChatProgramm.model.Client;
|
|
import ChatProgramm.model.Server;
|
|
import ChatProgramm.util.OhmLogger;
|
|
import ChatProgramm.view.ChatView;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
import java.io.IOException;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
*
|
|
* @author Js-Sc
|
|
*/
|
|
public class CommandConnectV2 implements ActionListener {
|
|
|
|
private static Logger lg = OhmLogger.getLogger();
|
|
private ChatView view;
|
|
private ChatModel model;
|
|
|
|
public CommandConnectV2(ChatView view, ChatModel model) {
|
|
this.view = view;
|
|
this.model = model;
|
|
}
|
|
|
|
public void registerEvents() {
|
|
view.getBtnConnect().addActionListener(this);
|
|
}
|
|
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
if (view.getBtnClient().isSelected()) {
|
|
lg.info("Server ausgewählt");
|
|
try {
|
|
model.setTransmitter(new Server(view, model));
|
|
} catch (IOException ex) {
|
|
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
|
|
}
|
|
}
|
|
|
|
if (view.getBtnServer().isSelected()) {
|
|
lg.info("Client ausgewählt");
|
|
try {
|
|
model.setTransmitter(new Client(view, model));
|
|
} catch (IOException ex) {
|
|
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
|
|
|
|
}
|
|
}
|
|
|
|
view.getjDialog1().setVisible(false);
|
|
}
|
|
|
|
}
|