Server/Client verbindung durch rBtn

This commit is contained in:
Jens Schuhmann 2023-12-11 18:05:46 +01:00
parent 4a7f17b1dc
commit 0853e26034
2 changed files with 40 additions and 3 deletions

View File

@ -36,7 +36,7 @@ public class CommandController implements ActionListener{
}
public void registerCommands(){
invoker.addCommand(view.getBtnConnect(), new CommandConnect());
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view));
invoker.addCommand(view.getTfNachricht(), new CommandSend());
}

View File

@ -5,20 +5,57 @@
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
*/
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
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