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.

Start.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 chatprogramm;
  7. import controller.ConnectController;
  8. import controller.ReceiveAdapter;
  9. import controller.SendController;
  10. import javax.swing.JOptionPane;
  11. import static javax.swing.JOptionPane.CLOSED_OPTION;
  12. import javax.swing.UIManager;
  13. import model.Transmitter;
  14. import view.ChatView;
  15. /**
  16. *
  17. * @author Apollo
  18. */
  19. public class Start
  20. {
  21. public Start()
  22. {
  23. //Auswahl für Server oder Client
  24. String[] options = {"Server","Client"};
  25. int entscheidung = JOptionPane.showOptionDialog(null, "Server oder Client Modus?","Auswahl des Operationmoduses",JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
  26. if(entscheidung == CLOSED_OPTION)
  27. {
  28. JOptionPane.showMessageDialog(null, "Unbekannter Fehler");
  29. System.exit(0);
  30. }
  31. //
  32. ChatView view = new ChatView();
  33. if(entscheidung==0) view.setTitle("Server");
  34. if(entscheidung==1) view.setTitle("Client");
  35. Transmitter model = new Transmitter(entscheidung);
  36. ConnectController conncontroller = new ConnectController(view,model);
  37. Thread chatter = new Thread(model);
  38. chatter.start();
  39. SendController sendcontroller = new SendController(view,model);
  40. sendcontroller.registerEvents();
  41. ReceiveAdapter adapter = new ReceiveAdapter(view,model);
  42. adapter.registerEvents();
  43. view.setVisible(true);
  44. }
  45. /**
  46. * @param args the command line arguments
  47. */
  48. public static void main(String[] args)
  49. {
  50. try
  51. {
  52. for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
  53. if ("Nimbus".equals(info.getName())) {
  54. UIManager.setLookAndFeel(info.getClassName());
  55. }
  56. }
  57. }
  58. catch(Exception ex)
  59. {
  60. JOptionPane.showMessageDialog(null, "Fehler beim Aufrufen der Syseinstellungen");
  61. }
  62. new Start();
  63. }
  64. }