Main.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package holeg.ui.view.main;
  2. import javax.swing.*;
  3. import holeg.ui.controller.Control;
  4. import holeg.ui.controller.IndexTranslator;
  5. import holeg.model.Model;
  6. import java.awt.*;
  7. import java.io.FileInputStream;
  8. import java.io.IOException;
  9. import java.util.Locale;
  10. import java.util.logging.Level;
  11. import java.util.logging.LogManager;
  12. import java.util.logging.Logger;
  13. /**
  14. * The main Class in this Program. The GUI is created in this Class.
  15. *
  16. * @author Gruppe14
  17. */
  18. public class Main {
  19. private static final LogManager logManager = LogManager.getLogManager();
  20. private static final Logger log = Logger.getLogger(Main.class.getName());
  21. static {
  22. try {
  23. logManager.readConfiguration(new FileInputStream("./config/log.properties"));
  24. } catch (IOException exception) {
  25. log.log(Level.SEVERE, "Error in loading configuration", exception);
  26. }
  27. }
  28. /**
  29. * main method of this program.
  30. *
  31. * @param args standard
  32. */
  33. public static void main(String[] args) {
  34. setLookAndFeel();
  35. setLocale();
  36. EventQueue.invokeLater(() -> {
  37. Model model = new Model();
  38. Control control = new Control(model);
  39. GUI view = new GUI(control);
  40. view.setVisible(true);
  41. });
  42. }
  43. private static void setLocale() {
  44. Locale.setDefault(Locale.US);
  45. }
  46. /**
  47. * This method loads the System LookAndFeel. Except for Linux OS.
  48. */
  49. private static void setLookAndFeel() {
  50. try {
  51. if (!System.getProperty("os.name").startsWith("Linux")) {
  52. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  53. }
  54. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  55. | UnsupportedLookAndFeelException e) {
  56. }
  57. }
  58. }