Main.java 1.8 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.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. */
  19. public class Main {
  20. private static final LogManager logManager = LogManager.getLogManager();
  21. private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
  22. static{
  23. try {
  24. logManager.readConfiguration(new FileInputStream("./config/log.properties"));
  25. } catch (IOException exception) {
  26. LOGGER.log(Level.SEVERE, "Error in loading configuration",exception);
  27. }
  28. }
  29. /**
  30. * main method of this program.
  31. *
  32. * @param args standard
  33. */
  34. public static void main(String[] args) {
  35. setLookAndFeel();
  36. setLocale();
  37. EventQueue.invokeLater(() -> {
  38. Model model = new Model();
  39. Control control = new Control(model);
  40. GUI view = new GUI(control);
  41. IndexTranslator.model = model;
  42. view.setVisible(true);
  43. });
  44. }
  45. private static void setLocale() {
  46. Locale.setDefault(Locale.US);
  47. }
  48. /**
  49. * This method loads the System LookAndFeel. Except for Linux OS.
  50. */
  51. private static void setLookAndFeel() {
  52. try {
  53. if (!System.getProperty("os.name").startsWith("Linux")) {
  54. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  55. }
  56. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  57. | UnsupportedLookAndFeelException e) {
  58. }
  59. }
  60. }