0

This is how i am setting a JFrame to full screen mode :

//set full screen            

frame.dispose();
frame.setUndecorated(true);
screenDevice.setFullScreenWindow(frame);
frame.setVisible(true);

//reset to window mode

frame.dispose();
screenDevice.setFullScreenWindow(null);
frame.setUndecorated(false);
frame.setVisible(true);

But, when i display any dialog, something like settings dialog, the dialog and full screen frame both lost their foucs and disappear on screen. Then i need to click in the taskbar icon to get the focus.

How to solve this issue ? Thank you.

Edit:

Suppose if there is a JMenuItem in the menu bar of this full screen window, then i am making visible a settings JDialog by clicking the menuitem like this:

settingsMenuItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        settingsDialog.showSettingsDialog();
    }
});

The settingsDialog and full screen are not showing on the screen in full screen mode. in window mode it works normally.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Sanjeev
  • 397
  • 1
  • 8
  • 20

2 Answers2

3

If you want to set your JFrame to maximized why not use this:

frame.setExtendedState(Frame.MAXIMIZED_BOTH); 
Sujay
  • 6,753
  • 2
  • 30
  • 49
  • i have tried your suggestion. i want to set the full screen mode, not to maximize state. – Sanjeev Sep 02 '12 at 05:06
  • 1
    @sanjeev: well you already have `frame.setUndecorated(...);` set to `true` and hence the suggestion. Also, consider posing an [SSCCE](http://sscce.org) of your code for us to better understand your issue – Sujay Sep 02 '12 at 05:09
  • 1
    @Sanjeev: See also [`FullScreenTest`](http://stackoverflow.com/a/7457102/230513). – trashgod Sep 02 '12 at 13:41
1
JFrame frame = new JFrame();   
GraphicsDevice window = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0]; 

//The number in the brackets decides what monitor the window gets "full-screened" to. 0 is the first, 1 is the second, ect.         
frame.setUndecorated(true);    
window.setFullScreenWindow(frame);    
frame.setVisible(true);    
frame.requestFocus();
DisplayName
  • 3,093
  • 5
  • 35
  • 42
zrubenst
  • 931
  • 9
  • 14