You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandConnect.java 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
  4. */
  5. package ChatProgramm.controller.commands;
  6. import ChatProgramm.model.Client;
  7. import ChatProgramm.model.Server;
  8. import ChatProgramm.util.OhmLogger;
  9. import ChatProgramm.view.ChatView;
  10. import java.io.IOException;
  11. import java.util.logging.Logger;
  12. import javax.swing.JDialog;
  13. import javax.swing.JRadioButton;
  14. /**
  15. *
  16. * @author ahren
  17. */
  18. public class CommandConnect implements CommandInterface
  19. {
  20. private JRadioButton rBtnServer;
  21. private JRadioButton rBtnClient;
  22. private JDialog dialogFenster;
  23. private static Logger lg = OhmLogger.getLogger();
  24. private CommandSend commandSend;
  25. private ChatView view;
  26. public CommandConnect(ChatView view, CommandInterface value)
  27. {
  28. rBtnServer = view.getBtnServer();
  29. rBtnClient = view.getBtnClient();
  30. dialogFenster = view.getjDialog1();
  31. commandSend = (CommandSend) value;
  32. this.view = view;
  33. }
  34. @Override
  35. public void execute()
  36. {
  37. if(rBtnServer.isSelected()){
  38. lg.info("Server ausgewählt");
  39. try {
  40. commandSend.transmitterInterface = new Server(view);
  41. } catch (IOException ex) {
  42. lg.info("Die Verbindung zum Server ist Fehlgeschlagen");
  43. }
  44. }
  45. if(rBtnClient.isSelected()){
  46. lg.info("Client ausgewählt");
  47. try {
  48. commandSend.transmitterInterface = new Client(view);
  49. } catch (IOException ex) {
  50. lg.info("Die Verbindung zum Client ist Fehlgeschlagen");
  51. }
  52. }
  53. dialogFenster.setVisible(false);
  54. }
  55. @Override
  56. public boolean isUndoable()
  57. {
  58. return false;
  59. }
  60. @Override
  61. public void undo()
  62. {
  63. }
  64. }