Q:

Problems With Creating a Fullscreen Mode Choosing Class

I was trying to creating a class that allowed me to select whether I wanted a fullscreen window or a normal JFrame window where I choose the size. Here's the code:
public class Frame extends JFrame {

boolean fse = false;
int fsm = 0;
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1];

public Frame(String title, int width, int height) {
    setTitle(title);
    setSize(width, height);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setResizable(false);
}

private void checkFullscreenMode() {
    switch(fsm) {
    case 0:
        setUndecorated(false);
        System.out.println("No Fullscreen");
        break;
    case 1:
        setUndecorated(true);
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        break;
    case 2:
        setUndecorated(true);
        device.setFullScreenWindow(this);
        break;
    }
}

public void setFullscreenMode(int fsnm) {
    fse = true;
    if(fsm <= 2) {
        this.fsm = fsnm;
    }
    else {
        System.err.println("Error: Mode " + fsnm + " is not Supported!");
    }
}

}
When I tried calling the method setFullscreenMode, it wouldn't work. No matter what mode I chose it just gave me a 1280 x 720 frame. Here's how I called it:
public class Main {
    public static void main(String[] args) {
        Frame frame = new Frame("TheDlooter", 1280, 720);
        frame.setFullscreenMode(1);
        frame.setVisible(true);
    }
}

A:

I realized that you are not calling checkFullscreenMode(). But actually this method making your frame full screen. So override the setVisible method in Frame and call checkFullscreenMode() in here.
Here is the working code:
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main {
    public static void main(String[] args) {
        Frame frame = new Frame("TheDlooter");
        frame.setFullscreenMode(1);
        frame.setVisible(true);
    }
}

class Frame extends JFrame {

    boolean fse = false;
    int fsm = 0;
    GraphicsDevice device =
    GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[1];

    public Frame(String title) {
        setTitle(title);

        add(new JLabel("ads"));

        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(false);
    }

    @Override
    public void setVisible(boolean b) {
        checkFullscreenMode();
        super.setVisible(b);
    }

    public void checkFullscreenMode() {
        switch (fsm) {
        case 0:
            setUndecorated(false);
            System.out.println("No Fullscreen");
            break;
        case 1:
            setUndecorated(true);
            setExtendedState(JFrame.MAXIMIZED_BOTH);
            break;
        case 2:
            setUndecorated(true);
            device.setFullScreenWindow(this);
            break;
        }
    }

    public void setFullscreenMode(int fsnm) {
        fse = true;
        if (fsm <= 2) {
            this.fsm = fsnm;
        } else {
            System.err.println("Error: Mode " + fsnm + " is not Supported!");
        }
    }
}

