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.

ConnectController.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package kommunikation.controller;
  7. import java.awt.event.ActionEvent;
  8. import java.awt.event.ActionListener;
  9. import javax.swing.JOptionPane;
  10. import kommunikation.transmitter.BilderKom;
  11. import kommunikation.transmitter.Transmitter;
  12. import kommunikation.view.ViewChat;
  13. /**
  14. *
  15. * @author Alexander_Christoph
  16. */
  17. public class ConnectController implements ActionListener
  18. {
  19. ViewChat view;
  20. BilderKom model;
  21. public ConnectController(ViewChat view, BilderKom model)
  22. {
  23. this.view = view;
  24. this.model = model;
  25. }
  26. public void registerEvents()
  27. {
  28. view.getBtnConnect().addActionListener(this);
  29. }
  30. @Override
  31. public void actionPerformed(ActionEvent arg0)
  32. {
  33. try
  34. {
  35. String ip = view.getTfIp().getText();
  36. int port = Integer.parseInt(view.getTfPort().getText());
  37. model.setIpPort(ip, port);
  38. }
  39. catch(NumberFormatException ex)
  40. {
  41. JOptionPane.showMessageDialog(null, "Bitte geben sie eine Zahl ein","Fehler", JOptionPane.ERROR_MESSAGE);
  42. }
  43. view.getTaChat().append("Verbinde\n");
  44. model.start();
  45. }
  46. }