Main.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.ui.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. IndexTranslator.model = model;
  41. view.setVisible(true);
  42. });
  43. }
  44. private static void setLocale() {
  45. Locale.setDefault(Locale.US);
  46. }
  47. /**
  48. * This method loads the System LookAndFeel. Except for Linux OS.
  49. */
  50. private static void setLookAndFeel() {
  51. try {
  52. if (!System.getProperty("os.name").startsWith("Linux")) {
  53. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  54. }
  55. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  56. | UnsupportedLookAndFeelException e) {
  57. }
  58. }
  59. }