Forum Stats

  • 3,768,544 Users
  • 2,252,807 Discussions
  • 7,874,616 Comments

Discussions

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

HopeSpartan
HopeSpartan Member Posts: 2 Green Ribbon

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?