MainFrame.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package gui.frames;
  2. import gui.menubar.MenuBar;
  3. import gui.panels.agenda.AgendaPane;
  4. import gui.panels.edit.EditPane;
  5. import gui.panels.table.Table;
  6. import java.awt.Window;
  7. import java.lang.reflect.InvocationTargetException;
  8. import java.lang.reflect.Method;
  9. import javax.swing.JFrame;
  10. import javax.swing.JPanel;
  11. import agenda.Agenda;
  12. @SuppressWarnings("serial")
  13. public class MainFrame extends JFrame{
  14. public enum Views{EDITOR, SIMULATOR, AGENDA, TABLE};
  15. private Agenda agenda;
  16. private JPanel currentPanel;
  17. public MainFrame(){
  18. this.agenda = new Agenda();
  19. this.currentPanel = new Table(this.agenda);
  20. this.add(this.currentPanel);
  21. this.setResizable(true);
  22. this.setBounds(100,100,1440,900);
  23. this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  24. this.setUndecorated(false);
  25. this.setJMenuBar(new MenuBar(this));
  26. this.setVisible(true);
  27. if(System.getProperties().getProperty("os.name").equals("Mac OS X")) {
  28. try {
  29. Class c = Class.forName("com.apple.eawt.FullScreenUtilities");
  30. Method m = c.getMethod("setWindowCanFullScreen", Window.class, Boolean.TYPE);
  31. m.invoke(c, this, true);
  32. } catch (ClassNotFoundException e) {
  33. e.printStackTrace();
  34. } catch (NoSuchMethodException e) {
  35. e.printStackTrace();
  36. } catch (InvocationTargetException e) {
  37. e.printStackTrace();
  38. } catch (IllegalAccessException e) {
  39. e.printStackTrace();
  40. }
  41. }
  42. }
  43. public void changeView(Views view){
  44. switch(view){
  45. case EDITOR:
  46. this.updateView(new EditPane(this.agenda));
  47. break;
  48. case AGENDA:
  49. this.updateView(new AgendaPane(this.agenda));
  50. break;
  51. case SIMULATOR:
  52. //komt later nog.
  53. break;
  54. case TABLE:
  55. this.updateView(new Table(this.agenda));
  56. break;
  57. }
  58. }
  59. private void updateView(JPanel panel){
  60. this.currentPanel = panel;
  61. this.setContentPane(this.currentPanel);
  62. this.revalidate();
  63. }
  64. }