Explorar el Código

Full screen support for OSX (Reflection used).

Gilian Joosen hace 10 años
padre
commit
c7cfb7c904

+ 20 - 0
src/gui/frames/MainFrame.java

@@ -9,6 +9,10 @@ import javax.swing.JPanel;
 
 import agenda.Agenda;
 
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 @SuppressWarnings("serial")
 public class MainFrame extends JFrame{
 	
@@ -27,6 +31,22 @@ public class MainFrame extends JFrame{
 		this.setUndecorated(false);
 		this.setJMenuBar(new MenuBar(this));
 		this.setVisible(true);
+
+        if(System.getProperties().getProperty("os.name").equals("Mac OS X")) {
+            try {
+                Class c = Class.forName("com.apple.eawt.FullScreenUtilities");
+                Method m = c.getMethod("setWindowCanFullScreen", Window.class, Boolean.TYPE);
+                m.invoke(c, this, true);
+            } catch (ClassNotFoundException e) {
+                e.printStackTrace();
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
 	}
     
     public void changeView(Views view){

+ 3 - 0
src/gui/main/Main.java

@@ -4,6 +4,9 @@ import gui.frames.MainFrame;
 
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
+import java.awt.*;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 
 public class Main {

+ 5 - 14
src/gui/menubar/MenuBar.java

@@ -1,11 +1,16 @@
 package gui.menubar;
 
 import gui.frames.MainFrame;
+import gui.main.Main;
+import javafx.stage.*;
 
 import java.awt.*;
+import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 import javax.swing.*;
 
@@ -41,7 +46,6 @@ public class MenuBar extends JMenuBar{
         JMenuItem editorView = new JMenuItem("Editor");
         JMenuItem agendaView = new JMenuItem("Agenda");
         JMenuItem simulatorView = new JMenuItem("Simulator");
-        JMenuItem fullScreen = new JMenuItem("Full screen");
 
         newAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
         openAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
@@ -117,19 +121,6 @@ public class MenuBar extends JMenuBar{
 
             }
         });
-        
-        /*viewMenu.add(fullScreen);
-        fullScreen.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if(System.getProperties().getProperty("os.name").equals("Mac OS X")) {
-                    com.apple.eawt.FullScreenUtilities.setWindowCanFullScreen(mainFrame, true);
-                    com.apple.eawt.Application.getApplication().requestToggleFullScreen(mainFrame);
-                }else{
-                    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
-                }
-            }
-        });*/
 	}
 	
 }

+ 0 - 23
src/gui/panels/edit/infoPanes/ActInfo.java

@@ -1,23 +0,0 @@
-package gui.panels.edit.infoPanes;
-
-import javax.swing.*;
-import javax.swing.border.Border;
-import java.awt.*;
-
-/**
- * Created by gjoosen on 20/02/15.
- */
-public class ActInfo extends JPanel {
-    
-    public ActInfo(){
-        super.setLayout(new BorderLayout());
-        super.add(new JButton("act"), BorderLayout.CENTER);
-        super.add(new JButton("act"));
-        super.add(new JButton("act"));
-        super.add(new JButton("act"));
-        super.invalidate();
-        super.validate();
-        super.repaint();
-    }
-    
-}