Java JFrame fullScreenWithAPI(JFrame w)

Here you can find the source of fullScreenWithAPI(JFrame w)

Description

full Screen With API

License

Apache License

Declaration

private static void fullScreenWithAPI(JFrame w) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import javax.swing.JFrame;

public class Main {
    private static void fullScreenWithAPI(JFrame w) {
        Rectangle r = null;//from w w w  . ja  v a 2s .  c  o  m
        GraphicsEnvironment ge = GraphicsEnvironment
                .getLocalGraphicsEnvironment();
        GraphicsDevice[] gs = ge.getScreenDevices();
        GraphicsDevice gd = w.getGraphicsConfiguration().getDevice();
        if (gs.length > 0) {
            GraphicsDevice device = gs[0];
            //GraphicsDevice device = gd;
            if (device.isFullScreenSupported()) {
                System.out.println("Full screen supported"); //$NON-NLS-1$
            } else {
                System.out.println("Full screen not supported"); //$NON-NLS-1$
            }
            device.setFullScreenWindow(w);
            w.setVisible(true);
            r = new Rectangle(0, 0, device.getDisplayMode().getWidth(),
                    device.getDisplayMode().getHeight());
        }
        if (r == null) {
            r = GraphicsEnvironment.getLocalGraphicsEnvironment()
                    .getMaximumWindowBounds();
        }
        w.setBounds(r);
        //System.out.println(r);
        w.setExtendedState(Frame.MAXIMIZED_BOTH);
    }
}

Related

  1. findJFrame(Component c)
  2. findJFrame(Component myComponent)
  3. fitToDesktop(final JFrame frame)
  4. fullScreen(JFrame window)
  5. fullScreenUsingMaximise(JFrame w)
  6. getFileSelection(JFrame parent, boolean onlyDirectories, String startingDir)
  7. getJFrame(Component cmp)
  8. getjFrame(int width, int height)
  9. getJFrame(JPanel panel, String title, int width, int height)