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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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,entscheidung);
  37. conncontroller.registerEvents();
  38. SendController sendcontroller = new SendController(view,model);
  39. sendcontroller.registerEvents();
  40. ReceiveAdapter adapter = new ReceiveAdapter(view,model);
  41. adapter.registerEvents();
  42. view.setSize(800,600);
  43. view.setLocationRelativeTo(null);
  44. view.setVisible(true);
  45. }
  46. /**
  47. * @param args the command line arguments
  48. */
  49. public static void main(String[] args)
  50. {
  51. try
  52. {
  53. for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
  54. if ("Nimbus".equals(info.getName())) {
  55. UIManager.setLookAndFeel(info.getClassName());
  56. }
  57. }
  58. }
  59. catch(Exception ex)
  60. {
  61. JOptionPane.showMessageDialog(null, "Fehler beim Aufrufen der Syseinstellungen");
  62. }
  63. new Start();
  64. }
  65. }