示例#1
0
 MacOSXFrame(
     DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y)
     throws LWJGLException {
   setResizable(false);
   addWindowListener(this);
   addComponentListener(this);
   canvas = new MacOSXGLCanvas();
   canvas.setFocusTraversalKeysEnabled(false);
   add(canvas, BorderLayout.CENTER);
   boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
   setUndecorated(fullscreen || undecorated);
   if (fullscreen) {
     try {
       AccessController.doPrivileged(
           new PrivilegedExceptionAction() {
             public Object run() throws Exception {
               getDevice().setFullScreenWindow(MacOSXFrame.this);
               getDevice().setDisplayMode(requested_mode);
               java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
               /**
                * For some strange reason, the display mode is sometimes silently capped even
                * though the mode is reported as supported
                */
               if (requested_mode.getWidth() != real_mode.getWidth()
                   || requested_mode.getHeight() != real_mode.getHeight()) {
                 getDevice().setFullScreenWindow(null);
                 if (isDisplayable()) dispose();
                 throw new LWJGLException(
                     "AWT capped mode: requested mode = "
                         + requested_mode.getWidth()
                         + "x"
                         + requested_mode.getHeight()
                         + " but got "
                         + real_mode.getWidth()
                         + " "
                         + real_mode.getHeight());
               }
               return null;
             }
           });
     } catch (PrivilegedActionException e) {
       throw new LWJGLException(e);
     }
   }
   pack();
   resize(x, y, mode.getWidth(), mode.getHeight());
   setVisible(true);
   requestFocus();
   canvas.requestFocus();
   updateBounds();
 }
示例#2
0
 private static boolean isUndecorated() {
   return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
 }