Main.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 Class in this Program. The GUI is created in this Class.
  16. *
  17. * @author Gruppe14
  18. */
  19. public class Main {
  20. private static final LogManager logManager = LogManager.getLogManager();
  21. private static final Logger log = Logger.getLogger(Main.class.getName());
  22. static {
  23. try {
  24. logManager.readConfiguration(new FileInputStream("./config/log.properties"));
  25. } catch (IOException exception) {
  26. log.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. control.loadCategory();
  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 ignored) {
  58. }
  59. }
  60. }