コード例 #1
0
ファイル: GUIImpl.java プロジェクト: rockerdiaz/halfnes
  public synchronized void toggleFullScreen() {
    if (inFullScreen) {
      this.dispose();
      gd.setFullScreenWindow(null);
      canvas.setSize(NES_HEIGHT * screenScaleFactor, NES_WIDTH * screenScaleFactor);
      this.setUndecorated(false);
      this.setVisible(true);
      inFullScreen = false;
      buildMenus();
      // nes.resume();
    } else {
      setJMenuBar(null);
      gd = getGraphicsConfiguration().getDevice();
      if (!gd.isFullScreenSupported()) {
        // then fullscreen will give a window the size of the screen instead
        messageBox("Fullscreen is not supported by your OS or version of Java.");
      }
      this.dispose();
      this.setUndecorated(true);

      gd.setFullScreenWindow(this);
      this.setVisible(true);

      inFullScreen = true;
    }
  }
コード例 #2
0
ファイル: MainPanel.java プロジェクト: DrFuehrer/rdv
  private boolean enterFullScreenMode() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = ge.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
      GraphicsDevice device = devices[i];
      if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) {
        log.info("Switching to full screen mode.");

        frame.setVisible(false);

        try {
          device.setFullScreenWindow(frame);
        } catch (InternalError e) {
          log.error("Failed to switch to full screen exclusive mode.");
          e.printStackTrace();

          frame.setVisible(true);
          return false;
        }

        frame.dispose();
        frame.setUndecorated(true);
        frame.setVisible(true);
        frame.requestFocusInWindow();

        return true;
      }
    }

    log.warn("No screens available or full screen exclusive mode is unsupported on your platform.");

    postError("Full screen mode is not supported on your platform.");

    return false;
  }
コード例 #3
0
ファイル: ZombieFrame.java プロジェクト: Kratok/ZamZam2
  /**
   * ZombieFrame's constructor.
   *
   * @param contents Optional JPanel(s) to add to content pane. Arguments > 0 are ignored.
   */
  public ZombieFrame(JPanel... contents) {
    super("ZombieHouse");

    // Request keyboard focus for the frame.
    setFocusable(true);
    requestFocusInWindow();
    requestFocus();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setUndecorated(true);
    setResizable(false);
    setBackground(Color.BLACK);

    // The content pane. An optional JPanel may be passed into the
    // constructor. It creates an empty pane with a black background if
    // one isn't provided.
    pane = getContentPane();
    pane.setBackground(Color.BLACK);
    pane.setFocusable(false);
    pane.setVisible(true);
    if (contents.length > 0) {
      pane.add(contents[0]);
    }

    keys = new ZombieKeyBinds((JComponent) pane);

    // Get the graphics device information.
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphics = environment.getDefaultScreenDevice();

    pack();

    // Go full screen, if supported.
    if (graphics.isFullScreenSupported()) {
      try {
        graphics.setFullScreenWindow(this);
        // Having gone full screen, retrieve the display size.
        // size = Toolkit.getDefaultToolkit().getScreenSize();

        // This double-switching of setVisible is to fix a bug with
        // full-screen-exclusive mode on OS X. Versions 10.8 and later
        // don't send keyboard events properly without it.
        if (System.getProperty("os.name").contains("OS X")) {
          setVisible(false);
        }
      } catch (HeadlessException ex) {
        System.err.println(
            "Error: primary display not set or found. "
                + "Your experience of life may be suboptimal.");
        ex.printStackTrace();
      }
    } else {
      // If full-screen-exclusive mode isn't supported, switch to
      // maximized window mode.
      System.err.println("Full-screen-exclusive mode not supported.");
      setExtendedState(Frame.MAXIMIZED_BOTH);
    }
    setVisible(true);
  }
コード例 #4
0
ファイル: Main.java プロジェクト: ealarco1/SpaceEscape3D
 public void toggleToFullscreen() {
   GraphicsDevice device =
       GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
   DisplayMode[] modes = device.getDisplayModes();
   int i = 0; // note: there are usually several, let's pick the first
   settings.setResolution(modes[i].getWidth(), modes[i].getHeight());
   settings.setFrequency(modes[i].getRefreshRate());
   settings.setDepthBits(modes[i].getBitDepth());
   settings.setFullscreen(device.isFullScreenSupported());
   restart();
 }
コード例 #5
0
ファイル: FullScreen.java プロジェクト: unaguil/nu3a
 /** Realiza la inicializacion previa del modo pantalla completa. */
 private void init() {
   env = GraphicsEnvironment.getLocalGraphicsEnvironment();
   graphicsDevice = env.getDefaultScreenDevice();
   oldDisplayMode = graphicsDevice.getDisplayMode();
   if (!graphicsDevice.isFullScreenSupported()) {
     System.out.println("Full screen mode failed");
     System.exit(1);
   } else {
     GraphicsConfiguration gc = graphicsDevice.getDefaultConfiguration();
     window = new Frame(gc);
   }
 }
コード例 #6
0
ファイル: MainFrame.java プロジェクト: XaoZloHnH/hafen-client
 DisplayMode findmode(int w, int h) {
   GraphicsDevice dev = getGraphicsConfiguration().getDevice();
   if (!dev.isFullScreenSupported()) return (null);
   DisplayMode b = null;
   for (DisplayMode m : dev.getDisplayModes()) {
     int d = m.getBitDepth();
     if ((m.getWidth() == w)
         && (m.getHeight() == h)
         && ((d == 24) || (d == 32) || (d == DisplayMode.BIT_DEPTH_MULTI))) {
       if ((b == null)
           || (d > b.getBitDepth())
           || ((d == b.getBitDepth()) && (m.getRefreshRate() > b.getRefreshRate()))) b = m;
     }
   }
   return (b);
 }
コード例 #7
0
ファイル: kra.java プロジェクト: EvelusDevelopment/670-Deob
  public kra() throws Exception {
    GraphicsEnvironment var1 = GraphicsEnvironment.getLocalGraphicsEnvironment();
    this.b = var1.getDefaultScreenDevice();
    if (!this.b.isFullScreenSupported()) {
      GraphicsDevice[] var2 = var1.getScreenDevices();
      GraphicsDevice[] var3 = var2;

      for (int var4 = 0; ~var4 > ~var3.length; ++var4) {
        GraphicsDevice var5 = var3[var4];
        if (null != var5 && var5.isFullScreenSupported()) {
          this.b = var5;
          return;
        }
      }

      throw new Exception();
    }
  }
コード例 #8
0
  @Override
  public void start() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    gd = ge.getDefaultScreenDevice();

    if (!gd.isFullScreenSupported()) {
      onError("Full-screen exclusive mode not supported");
      System.exit(0);
    }
    // switch on FSEM
    //        gd.setFullScreenWindow(window);

    window.setVisible(true);

    renderThread.start();
    updateThread.start();
    inputThread.start();
  }
コード例 #9
0
ファイル: MainPanel.java プロジェクト: DrFuehrer/rdv
  private void leaveFullScreenMode() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = ge.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
      GraphicsDevice device = devices[i];
      if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) {
        log.info("Leaving full screen mode.");

        frame.setVisible(false);
        device.setFullScreenWindow(null);
        frame.dispose();
        frame.setUndecorated(false);
        frame.setVisible(true);

        break;
      }
    }
  }
コード例 #10
0
  public FullScreenFrame(final NodeBoxDocument document) {
    this.document = document;
    setLayout(new BorderLayout(0, 0));

    viewer = new Viewer();
    document.addZoomListener(viewer);
    add(viewer, BorderLayout.CENTER);

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

    if (gd.isFullScreenSupported()) {
      setUndecorated(true);
      gd.setFullScreenWindow(this);
    } else {
      System.err.println("Full screen not supported");
      setSize(100, 100); // just something to let you see the window
      setVisible(true);
    }
  }
コード例 #11
0
 public static void main(String[] args) {
   if (GraphicsEnvironment.isHeadless()) {
     System.out.println("no screen detected");
     return;
   } else {
     // <begin>
     IFacade facade = new asteroids.Facade();
     // <end>
     GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
     GraphicsDevice device = env.getDefaultScreenDevice();
     Asteroids asteroids;
     if (device.isFullScreenSupported()) {
       asteroids = new Asteroids(facade, true);
       device.setFullScreenWindow(asteroids);
     } else {
       asteroids = new Asteroids(facade, false);
     }
     asteroids.start();
   }
 }
コード例 #12
0
  private void enterFullscreen() {
    GraphicsDevice device = m_renderTarget.getGraphicsConfiguration().getDevice();

    if (!device.isFullScreenSupported())
      m_logger.error("Cannot enter full-screen. Device does not support full-screen mode");
    else {
      device.setFullScreenWindow(m_renderTarget);

      DisplayMode best = device.getDisplayMode();

      if (!device.isDisplayChangeSupported())
        m_logger.error(
            "Device does not support change of display modes. Using default display mode.");
      else {
        for (DisplayMode d : device.getDisplayModes()) {
          int dDeltaWidth = d.getWidth() - m_canvasRenderWidth;
          int dDeltaHeight = d.getHeight() - m_canvasRenderHeight;
          int dDeltaBitDepth = d.getBitDepth() - PREFERRED_BIT_DEPTH;

          int bestDeltaWidth = best.getWidth() - m_canvasRenderWidth;
          int bestDeltaHeight = best.getHeight() - m_canvasRenderHeight;
          int bestDeltaBitDepth = best.getBitDepth() - PREFERRED_BIT_DEPTH;

          if (dDeltaWidth == bestDeltaWidth && dDeltaHeight == bestDeltaHeight) {
            if (d.getBitDepth() > MIN_BIT_DEPTH
                && (Math.abs(dDeltaBitDepth) < Math.abs(bestDeltaBitDepth))) best = d;
          } else if (dDeltaWidth == 0
              || (dDeltaWidth > 0 && dDeltaWidth < bestDeltaWidth) && dDeltaHeight == 0
              || (dDeltaHeight > 0 && dDeltaHeight < bestDeltaWidth)) {
            best = d;
          }
        }
        device.setDisplayMode(best);
      }

      m_renderTarget.setBounds(
          new Rectangle(
              m_renderTarget.getLocation(), new Dimension(best.getWidth(), best.getHeight())));
    }
  }
コード例 #13
0
  public static void main(String agrs[]) {
    // Determine if full-screen mode is supported directly
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();
    if (gs.isFullScreenSupported()) {
      // Full-screen mode is supported
    } else {
      // Full-screen mode will be simulated
    }

    // Create a button that leaves full-screen mode
    Button btn = new Button("OK");
    btn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            // Return to normal windowed mode
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            gs.setFullScreenWindow(null);
          }
        });

    // Create a window for full-screen mode; add a button to leave full-screen mode
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);

    try {
      // Enter full-screen mode
      gs.setFullScreenWindow(win);
      win.validate();

      // ...
    } finally {
      // Exit full-screen mode
      gs.setFullScreenWindow(null);
    }
  }
コード例 #14
0
 public static void toFullScreen(
     JFrame window,
     GraphicsDevice gd,
     boolean tryAppleFullscreen,
     boolean tryExclusiveFullscreen) {
   if (appleEawtAvailable()
       && tryAppleFullscreen
       && appleOSVersion() >= 7
       && // lion and above
       javaVersion() >= 7) { // java 7 and above
     System.out.println("trying to apple fullscreen");
     enableAppleFullscreen(window);
     doAppleFullscreen(window);
   } else if (appleEawtAvailable()
       && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL
       tryExclusiveFullscreen
       && gd.isFullScreenSupported()) {
     if (javaVersion() >= 7) setAutoRequestFocus(window, true);
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     // window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     gd.setFullScreenWindow(window);
     window.toFront();
     Rectangle r = gd.getDefaultConfiguration().getBounds();
     window.setBounds(r);
     // window.pack();
   } else { // Windows and Linux TODO: test this
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight());
     window.setLocation(0, 0);
     window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     window.toFront();
   }
   window.pack();
   window.setVisible(true);
 }