Main.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package holeg.ui.view;
  2. import holeg.model.Model;
  3. import holeg.ui.controller.Control;
  4. import holeg.ui.view.main.Gui;
  5. import java.awt.EventQueue;
  6. import java.io.FileInputStream;
  7. import java.io.IOException;
  8. import java.util.Locale;
  9. import java.util.logging.Level;
  10. import java.util.logging.LogManager;
  11. import java.util.logging.Logger;
  12. import javax.swing.UIManager;
  13. import javax.swing.UnsupportedLookAndFeelException;
  14. /**
  15. * The main entry of this program.
  16. */
  17. public class Main {
  18. private static final LogManager logManager = LogManager.getLogManager();
  19. private static final Logger log = Logger.getLogger(Main.class.getName());
  20. static {
  21. //Initialize logging
  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. * No arguments are evaluated.
  31. * Sets the look and feel, creates the gui and start the EventQueue.
  32. * @param args arguments
  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. control.loadCategory();
  42. view.setVisible(true);
  43. });
  44. }
  45. /**
  46. * Sets the locale.
  47. */
  48. private static void setLocale() {
  49. Locale.setDefault(Locale.US);
  50. }
  51. /**
  52. * This method loads the System LookAndFeel. Except for Linux OS.
  53. */
  54. private static void setLookAndFeel() {
  55. try {
  56. if (!System.getProperty("os.name").startsWith("Linux")) {
  57. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  58. }
  59. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
  60. | UnsupportedLookAndFeelException ignored) {
  61. }
  62. }
  63. }