Browse Source

Server/Client verbindung durch rBtn

Jens
Jens Schuhmann 1 year ago
parent
commit
0853e26034

+ 1
- 1
src/ChatProgramm/controller/CommandController.java View File

} }
public void registerCommands(){ public void registerCommands(){
invoker.addCommand(view.getBtnConnect(), new CommandConnect());
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view));
invoker.addCommand(view.getTfNachricht(), new CommandSend()); invoker.addCommand(view.getTfNachricht(), new CommandSend());
} }



+ 39
- 2
src/ChatProgramm/controller/commands/CommandConnect.java View File



package ChatProgramm.controller.commands; package ChatProgramm.controller.commands;


import ChatProgramm.Client;
import ChatProgramm.Server;
import ChatProgramm.util.OhmLogger;
import ChatProgramm.view.ChatView;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JRadioButton;

/** /**
* *
* @author ahren * @author ahren
*/ */
public class CommandConnect implements CommandInterface public class CommandConnect implements CommandInterface
{ {
public CommandConnect()
private JRadioButton rBtnServer;
private JRadioButton rBtnClient;
private JDialog dialogFenster;
private static Logger lg = OhmLogger.getLogger();
public CommandConnect(ChatView view)
{ {
rBtnServer = view.getBtnServer();
rBtnClient = view.getBtnClient();
dialogFenster = view.getjDialog1();
} }


@Override @Override
public void execute() public void execute()
{ {
if(rBtnServer.isSelected()){
lg.info("Server ausgewählt");
try {
new Server();
} catch (IOException ex) {
lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
}
}
if(rBtnClient.isSelected()){
lg.info("Client ausgewählt");
try {
new Client();
} catch (IOException ex) {
lg.info("Die Verbindung zum Client ist Fehlgeschlagen");

}
}
dialogFenster.setVisible(false);
} }


@Override @Override

Loading…
Cancel
Save