When I get to the section “the following is equivalent”, I am trying to show how one would execute the vc.setFullScreenWindow(window) all in one command but I am confusing myself because I am pretty new to this.
That is my main question, but if anyone can just explain anything worth noting about the GraphicsEnvironment or the JFrame while they are at it, I’d be much obliged.
import java.awt.*;
import javax.swing.JFrame;
// Screens2 can use all methods that JFrame has
public class Screens2 extends JFrame{
// Video Card used for Utilizing the graphics on the computer SCREEN
private GraphicsDevice vc;
// The Constructor merely sets the default Screen graphics up
public Screens2(){
// The OS specific Graphics Envirionment
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
// Graphics Device vc = The Default();
vc = env.getDefaultScreenDevice();
}
// he DisplayMode class encapsulates the bit depth,
// height, width, and refresh rate of a GraphicsDevice.
// this method also takes in a JFrame to Display the DisplayMode
public void setFullScree(DisplayMode dm, JFrame window){
// Nothing fancy
window.setUndecorated(true);
window.setResizable(false);
// The following is equivalent =======================================================
private GraphicsDevice.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(window);
vc.setFullScreenWindow(window);
}
}
This line you mentioned is messed up a little:
The compiler assumes you want to create a private member variable inside a method. See Declaring Member Variables. Also the starting
GraphicsDeviceis not needed.Replace it with the following:
Check out Lesson: Full-Screen Exclusive Mode API for more details about full screen exclusive mode.
Consider the following example that demonstrates a frame in full screen mode: