Enabling Full-Screen Mode

In full-screen mode, no window can overlap the full-screen window. Also, when in full-screen mode, the display mode typically can be changed if desired (see Setting the Screen Size, Refresh Rate, or Number of Colors).
// Determine if full-screen mode is supported directly GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); if (gs.isFullScreenSupported()) { // Full-screen mode is supported } else { // Full-screen mode will be simulated } // Create a button that leaves full-screen mode Button btn = new Button("OK"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // Return to normal windowed mode GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); gs.setFullScreenWindow(null); } }); // Create a window for full-screen mode; add a button to leave full-screen mode Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); win.add(btn, BorderLayout.CENTER); try { // Enter full-screen mode gs.setFullScreenWindow(win); win.validate(); // ... } finally { // Exit full-screen mode gs.setFullScreenWindow(null); }

Comments

30 Jan 2010 - 4:09am by haka (not verified)

thanks

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.