Here you can find the source of fullScreenWithAPI(JFrame w)
private static void fullScreenWithAPI(JFrame w)
//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); } }