Main.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package ui.view;
  2. import ui.controller.Control;
  3. import ui.controller.SingletonControl;
  4. import ui.model.Model;
  5. import javax.swing.*;
  6. import javax.swing.UIManager.LookAndFeelInfo;
  7. import java.awt.*;
  8. /**
  9. * The main Class in this Program. The GUI is created in this Class.
  10. *
  11. * @author Gruppe14
  12. *
  13. */
  14. public class Main {
  15. /**
  16. * main method of this program.
  17. *
  18. * @param args
  19. * standard
  20. */
  21. public static void main(String[] args) {
  22. //System.out.println(System.getProperty("os.name"));
  23. // if (!System.getProperty("os.name").startsWith("Linux")) {
  24. // // *Design
  25. // try {
  26. //
  27. // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  28. // } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
  29. // e.printStackTrace();
  30. // }
  31. // }else {
  32. //// try {
  33. //// UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
  34. //// } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  35. //// | UnsupportedLookAndFeelException e) {
  36. //// e.printStackTrace();
  37. //// }
  38. // }
  39. if (System.getProperty("os.name").startsWith("Linux")) {
  40. try {
  41. UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
  42. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  43. | UnsupportedLookAndFeelException e) {
  44. e.printStackTrace();
  45. }
  46. }else {
  47. loadNotLinuxLookAndFeel();
  48. }
  49. EventQueue.invokeLater(() -> {
  50. try {
  51. Model model = new Model();
  52. Control control = new Control(model);
  53. SingletonControl.getInstance().setControl(control);
  54. GUI view = new GUI(control);
  55. view.getFrmCyberPhysical().setVisible(true);
  56. } catch (Exception e) {
  57. e.printStackTrace();
  58. }
  59. });
  60. }
  61. private static void loadNotLinuxLookAndFeel() {
  62. try {
  63. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  64. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
  65. e.printStackTrace();
  66. }
  67. }
  68. }