Skip to Main Content

Why setResizable(boolean ) method supress Full Screen Exclusive Mode?

HopeSpartanAug 30 2021 — edited Dec 5 2022

I wrote a code :

public class GameWindow extends JFrame implements WindowListener {

    public GameWindow( ) {
        super("Window");
        DisplayMode origDisplayMode = null;
        GraphicsDevice graphicsDevice= null ;
        GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice\[\] devices = graphicsEnvironment.getScreenDevices();
        //  put graphical devices into array 
        for(int cnt = 0;cnt \< 1;cnt++){
            System.out.println(devices\[cnt\]);
        }

        //Construct a full-screen object using the first/ active graphicsDevice which has 0 index
        graphicsDevice= devices\[0\];
        if (graphicsDevice.isFullScreenSupported()){
            // Enter full-screen mode witn an undecorated,non-resizable JFrame object
            setExtendedState(JFrame.MAXIMIZED\_BOTH);
            setTitle("FRAME MAX");
            setUndecorated(true);
            setResizable(false);
            graphicsDevice.setFullScreenWindow(this);
            revalidate();
            repaint();
            Toolkit.getDefaultToolkit().sync(); // to make graphics sync for Linux
            System.out.println("OK Full-screen mode is supported");
        } else {
            System.out.println("XX Full-screen mode is not supported");
        }
        origDisplayMode = graphicsDevice.getDisplayMode();
        // get dimensions from display mode 
        Dimension dim=new Dimension(origDisplayMode.getWidth(),origDisplayMode.getHeight());
        setSize(dim);
        setPreferredSize(dim);
        setMinimumSize(dim);
        setLocationRelativeTo(null);
}

public static void main(String\[\] args) {
        AppStarter starter = new AppStarter( args );
        SwingUtilities.invokeLater( starter );
    }
}

class AppStarter extends Thread
{
    private String\[\] args;


    public AppStarter( String\[\] args )
    {
        this.args = args;
    }
    
    public void run()
    {   //start program here 
        GameWindow gw=new GameWindow();
        gw.setDefaultCloseOperation(WindowConstants.DISPOSE\_ON\_CLOSE);
        gw.setVisible(true);
        
    }
}

However, title bar remains there! I just delete "setResizable(false) line and FSEM works like a charm ! Why?

Comments
Post Details
Added on Aug 30 2021
1 comment
15 views